Fetch JSON data based on email using PHP


April 2019


11 time


HI there What I want is to fetch the User Data based on the email ID From The JSON File.

the Json Data is in this Format .

"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "[email protected]",
"address": {
  "street": "Kulas Light",
  "suite": "Apt. 556",
  "city": "Gwenborough",
  "zipcode": "92998-3874",
  "geo": {
    "lat": "-37.3159",
    "lng": "81.1496"
"phone": "1-770-736-8031 x56442",
"website": "hildegard.org",
"company": {
  "name": "Romaguera-Crona",
  "catchPhrase": "Multi-layered client-server neural-net",
  "bs": "harness real-time e-markets"
"id": 2,
"name": "Ervin Howell",
"username": "Antonette",
"email": "[email protected]",
"address": {
  "street": "Victor Plains",
  "suite": "Suite 879",
  "city": "Wisokyburgh",
  "zipcode": "90566-7771",
  "geo": {
    "lat": "-43.9509",
    "lng": "-34.4618"
 and so on....

Now What Exactly I Want is that I want to show particular user data based on its unique id or Email id,

I Can Fetch the data using curl That I know .. Like this..

$url ="" ;
$ch = curl_init() ;

 curl_setopt($ch, CURLOPT_URL, $url) ;
 curl_setopt($ch, CURLOPT_HEADER, false);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    
 $users_result = curl_exec($ch);

 curl_close($ch) ;
 $reg_user_count = 0 ;
 $users_data = json_decode($users_result, true) ;

But How Can I fetch the single user data based on its unique id or email. on to another page . Like a single profile page.

0 answers