First of all: Yes i did check other answers but they sadly didn't do the trick.
So i'm currently working on a script that checks if an email exists in the database. So the database data is obtained through a webservice and with an input filter function the following JSON object is returned:
{"customers":{"customer":{"lastname":"test","firstname":"login","email":"[email protected]"}}}
Now i would like to check if the email is filled in correctly. I'm using a foreach() statement to compare the values but i'm always getting a not found returned. Maybe someone here is able to find the mistake i've made. So the full code is shown down below.
$resultEmail = ($webService->get( $optUser ));
$emailResult = json_encode($resultEmail);
$emailArray = json_decode($resultEmail);
echo ($emailResult);
echo ($chopEmail);
foreach($emailArray->customers->customer as $item)
{
if($item->email == $email)
{
echo "found it!";
}
}
// The $optUser is the JSON object
$emailResultis a json object. You can not use it in array.foreachif anStdClassis passed to itStdClassit seems...