I have some code, but I think it maybe more simple.
Maybe you can halp me, do this.
$array_product = array ('1,2,3,4,5','5,7,8,9,5','1,5,7,8,9');
$table = array();
for($i = 0;$i<count($array_product) ;$i++)
{
$arr = preg_split('/,/',$array_product[$i]);
foreach($arr as $val)
{
$table[$i][]=$val;
}
}
print_r($table);
Thanks!
$array_product = array ('1,2,3,4,5','5,7,8,9,5','1,5,7,8,9');
$table = array_map(function($val) {
return explode(",", $val);
}, $array_product);
print_r($table);
$table = array_map(function($x){return explode(',',$x);}, $array_product);
You can make it simple, readable and optimized as below :
$arrayProduct = array ('1,2,3,4,5', '5,7,8,9,5', '1,5,7,8,9');
$table = array();
foreach ($arrayProduct as $values) {
$arr = explode(',', $values);
$table[] = $arr;
}
print_r($table);