Test in some json code, like [{"a":"1"},{"a":"2"},{"a":"3"},{"b":"2"}], I want use json decode, get the data and make a judge, if first a nod is == b nod or fisrt a nod is != b nod. some code here.
<?php
header("Content-type: text/html; charset=utf-8");
$json = json_decode('[{"a":"1"},{"a":"2"},{"a":"3"},{"b":"2"}]',true);
$number=1;
foreach($json as $num){
if($num['a']!=$num['b']){
if($num['a']){
echo 'a'.$number.''.$num['a'].'<br />';
}
}else{
if($num['a']){
echo 'b'.$number.''.$num['a'].'<br />';
}
}
$number++;
}
?>
Now my result is:
a11
a22
a33
And I need get the result:
a11
b22
a33
$num['a']and make out which$num['a']is equal to$num['b']such asa11,b22,a33