【发布时间】:2012-09-25 09:10:00
【问题描述】:
如何分解数组中的每个元素?
Array
(
[0] => countryId:2, productId:1, status:1, pId:18, xId:pdgje5566
)
请看下面的数组:
$searchfor = $xId;
header('Content-Type: text/plain');
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
print_r($matches[0]);
//echo implode("\n", $matches[0]);
}
请指教,谢谢。
【问题讨论】:
-
数组中的每个元素是字符串还是二维数组的 JSON 表示?还有你想分什么?
-
@Sammaye 数据来自文本文件