Answers for "php array to json converter"

PHP
10

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
15

json php

//Json Encode

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

//Json Decode

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

$person = json_decode($personJSON);

echo $person->name; // KINGASV
Posted by: Guest on July-16-2020
8

php json_encode

$person = array( 
    "name" => "Johny Carson", 
    "title" => "CTO"
); 
$personJSON=json_encode($person);//returns JSON string
Posted by: Guest on July-01-2019
0

convert json to array in php

<?php
  // Loop through Array
  $someArray = ...; // Replace ... with your PHP Array
  foreach ($someArray as $key => $value) {
    echo $value["name"] . ", " . $value["gender"] . "<br>";
  }

  // Loop through Object
  $someObject = ...; // Replace ... with your PHP Object
  foreach($someObject as $key => $value) {
    echo $value->name . ", " . $value->gender . "<br>";
  }
?>
Posted by: Guest on June-08-2021

Browse Popular Code Answers by Language