php爆炸数组中的元素

con*_*men 0 php arrays explode

我怎么能爆炸数组中的每个元素?

Array
(
    [0] => countryId:2, productId:1, status:1, pId:18, xId:pdgje5566
)
Run Code Online (Sandbox Code Playgroud)

请看以下数组:

$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]);

}
Run Code Online (Sandbox Code Playgroud)

请指教,谢谢.

xda*_*azz 8

foreach ($array as &$value) {
  $arr = array();
  foreach (explode(', ', $value) as $el) {
     $ret = explode(':', $el);
     arr[$ret[0]] = $ret[1];
  }
  $value = $arr;
}
Run Code Online (Sandbox Code Playgroud)