I wonder if someone can help me extract values from an array by key value rather than array number.
$json = json_decode($stock, true);
print_r($json);
$sims = $json['stock'][1]['sims'];
foreach ($sims as $sim)
{
echo nl2br($sim . "\n");
}
The output from print_r($json) is:
Array ( [stock] => Array (
[0] => Array
( [operator] => ECL [sims] => Array
( [0] => 8944122616994 [1] => 89650264517182 [2] => 894412265075 [3] => 894412 ) )
[1] => Array
( [operator] => JT [sims] => Array
( [0] => 89445023065 [1] => 894156673081 [2] => 8944501 [3] => 89445027 ) ) ) )
It appears that sometimes the data I want is not in array number 1 hence I would like to extract it based on "[operator] => JT" I've been trying various ideas but it never seems to work.