Answers for "encode array as json php"

PHP
20

php convert array to json object

$myArr = array("apple", "banana", "mango", "jackfruit");

$toJSON = json_encode($myArr);

echo $toJSON;
Posted by: Guest on June-18-2020
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

Browse Popular Code Answers by Language