“JSON para PHP Array” Respostas de código

PHP Convert Array em objeto JSON

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

$toJSON = json_encode($myArr);

echo $toJSON;
Lazy Loris

php json_decode

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

$person = json_decode($personJSON);

echo $person->name; // Johny Carson
Grepper

Arquivo JSON de decodificação php

$json = json_decode(file_get_contents('/path/to/your/file.json'));
Kaotik

JSON TO DRAY PHP

//2 ways
  //this is for string from $_REQUEST,$_POST to array
$jsonText = $_REQUEST['myJSON'];
$decodedText = html_entity_decode($jsonText);
$myArray = json_decode($decodedText, true);

//this is for json to array
$assosiative_array = json_decode(json_encode($jsonText),true);
Splendid Salmon

converter em json php

<?php
	// the php array
  	$array = array();
	$array['key1'] = "value1";
	$array['key2'] = "value2";
	$array['key3'] = "value3";

	// encode the php array into JSON format
	$json = json_encode($array);

	// check out the results
	var_dump($json);
?>
CoderHomie

JSON para PHP Array

<?php
        $json = '[{"name":"xxx","phone":"123","email":"[email protected]"},{"name":"yyy","phone":"456","email":"[email protected]"},{"name":"zzz","phone":"678","email":"[email protected]"}]';
        $json_decoded = json_decode($json);
        echo '<table>';
        foreach($json_decoded as $result){
          echo '<tr>';
            echo '<td>'.$result->name.'</td>';
            echo '<td>'.$result->phone.'</td>';
            echo '<td>'.$result->email.'</td>';
          echo '</tr>';
        }
        echo '</table>';
      ?>
Fierce Fly

Respostas semelhantes a “JSON para PHP Array”

Perguntas semelhantes a “JSON para PHP Array”

Mais respostas relacionadas para “JSON para PHP Array” em PHP

Procure respostas de código populares por idioma

Procurar outros idiomas de código