json_encode php
snippet in php

php json encode

user8370

$person = array( 
    "name" => "Johny Carson", 
    "title" => "CTO"
); 
$personJSON=json_encode($person);//returns JSON string

json_encode php

user2644

<?php 
   
// Declare an array  
$value = array( 
    "name"=>"GFG", 
    "email"=>"abc@gfg.com"); 
   
// Use json_encode() function 
$json = json_encode($value); 
   
// Display the output 
echo($json); 
   
?> 

json_encode php

user6727


  <?php
$age = array("Peter"=>"35", "Ben"=>"37", "Joe"=>"43");

  
echo json_encode($age);
?>
 

php echo json

user1807

<?php
$data = ['name' => 'John', 'age' => 35];
header('Content-type: Application/json');
echo json_encode($data);

json_encode php

user8337

<?php 
   
// Declare an array  
$value = array( 
    "name"=>"GFG", 
    "email"=>"abc@gfg.com"); 
   
// Use json_encode() function 
$json = json_encode($value); 
   
// Display the output 
echo($json); 
   
?>