Answers for "put php variable in json decode encode"

PHP
20

php json_decode

$personJSON = '{"name":"Johny Carson","title":"CTO"}';

$person = json_decode($personJSON);

echo $person->name; // Johny Carson
Posted by: Guest on July-01-2019
0

json_encode php

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

=====================================================
  
$function = "#!!function(){}!!#"; 
$message = "Hello";

$json = array(   
  'message' => $message,
  'func' => $function
);
$string = json_encode($json);
$string = str_replace('"#!!','',$string);
$string = str_replace('!!#"','',$string);
echo $string;
Posted by: Guest on February-28-2022

Code answers related to "put php variable in json decode encode"

Browse Popular Code Answers by Language