my code:
$customers='[
{
"id": 1,
"name": "sara",
"phone": 1100,
"mobile": 1111
},
{
"id": 2,
"name": "ben",
"phone": 2200,
"mobile": 2222
}
]';
$data = json_decode($customers, true);
foreach($data as $a){
if($a['name'] == 'sara'){
$phone = $a['phone'];
$mobile = $a['mobile'];
echo "sara's phone is $phone";
echo "sara's mobile is $mobile";
}
else{
echo "No customer found with this name";
}
}
my problem is:
just else part is working and if condition is not working but when i remove else part, if part is working good.
can you help me??