PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $arr = [ ["good" => 1, "material" => "salt"], ["good" => 1, "material" => "sugar"], ["good" => 5, "material" => "coffee"], ["good" => 5, "material" => "milk"], ["good" => 5, "material" => "cocoa"], ["good" => 11, "material" => "dumplings"] ]; for ($i = 0; $i < count($arr); $i++) { $str[$arr[$i]['good']] .= isset($str[$arr[$i]['good']]) ? ",".$arr[$i]["material"] : $arr[$i]["material"]; } var_dump($str);
Show:  
Copy Clear