Possible Duplicate:
PHP – Why is a concatenated print_r printed out of order?
the following is a piece of code which has $input in the format of S:2:0;M:7:9;L:4:9;XL:6:0;XXL:6:9 these are parsed and stored into the 2d array .. by the following code
$stock_data = explode(';', $input);
foreach($stock_data as $value) {
$value = explode(':', $value);
if (!empty($value[0])) {
$temp_size = $value[0];
$stock[$value[0]] = array('winkel' => $value[1], 'distributeur' => $value[2]);
fb('afetr array val = '.$temp_size.' = its val -|'. print_r($stock[$temp_size]['distributeur']).'|',FirePHP::INFO);
}
}
return $stock;
the values in the print_r($stock[$temp_size]['distributeur'] or print_r($stock[$temp_size]['winkel'] is always 1, even if later i try to print_r the whole array $stock, all it has got is 1.
I was trying for print_r() to show the array as it should be, What is going wrong here.
That’s because that’s what
print_rreturns. If you want it to return the string, add the 2nd parameter: