Why is the restructured array subscript always the first?
'10', 'name' => 'product 1'), array ('pid '=> '11', 'name' => 'product 2 ')); foreach ($ product as $ key = >$ value) {$ result_value = ""; foreach ($ value as $ k = >$ v) {$ result_value. = $ result_value? "|": ""; $ Result_value. = $ v ['pid'];} $ product [$ key] ['value'] = $ result_value;} $ resarr [$ num] = $ product; var_dump ($ resarr); echo"
";}
Var_dump () always returns the subscript [8... Where is the error?
Reply to discussion (solution)
Print out the loop
$ Id = array (8, 31, 32); $ resarr = array (); foreach ($ id as $ num) {$ product = array ('pid '=> '10', 'name' => 'product 1'), array ('pid' => '11 ', 'name' => 'product 2'); foreach ($ product as $ key => $ value) {$ result_value = ""; foreach ($ value as $ k =>$ v) {$ result_value. = $ result_value? "|": ""; $ Result_value. = $ v ['pid'];} $ product [$ key] ['value'] = $ result_value;} $ resarr [$ num] = $ product ;} var_dump ($ resarr); echo"
";
Thank you for the two men upstairs. I have too many prawns.