Answer the question
In order to leave comments, you need to log in
How to get that id where "email": "[email protected]"?
how to get that id where "email" : "[email protected]"?
<?php
echo "<hr>";
echo "<br>";
$json = '{
"Id" : {
"Name" : "Karen",
"email" : "[email protected]",
"password" : "123456"
},
"ID2" : {
"Name" : "Anush",
"email" : "[email protected]",
"password" : "1992120"
}
}';
Answer the question
In order to leave comments, you need to log in
In general, like this:
<?php
echo "<hr>";
echo "<br>";
$json = '{
"Id" : {
"Name" : "Karen",
"email" : "[email protected]",
"password" : "123456"
},
"ID2" : {
"Name" : "Anush",
"email" : "[email protected]",
"password" : "1992120"
}
}';
$decoded = json_decode($json);
$expectedValue;
foreach($decoded as $key=>$value) {
if($value->email=='[email protected]') {
$expectedValue = $key;
}
}
var_dump($expectedValue);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question