Skip to content

Instantly share code, notes, and snippets.

@sineld sineld/json-php.php
Created Apr 28, 2012

Embed
What would you like to do?
Json and php
<?php
$dizi = array('koca' => array('isim' => 'sinan', 'yas' => 31), 'es' => array('isim' => 'bilge', 'yas' => 22));
echo 'Php: ';
var_dump($dizi).'<br>';
$d = json_encode($dizi);
echo 'Json (encoded): ';
var_dump($d). '<br>';
echo 'Json (decoded): ';
var_dump(json_decode($d));
$d = json_decode(json_encode($dizi));
echo $d->es->isim;
?>
Php:
array
'koca' =>
array
'isim' => string 'sinan' (length=5)
'yas' => int 31
'es' =>
array
'isim' => string 'bilge' (length=5)
'yas' => int 22
Json (encoded):
string '{"koca":{"isim":"sinan","yas":31},"es":{"isim":"bilge","yas":22}}' (length=67)
Json (decoded):
object(stdClass)[1]
public 'koca' =>
object(stdClass)[2]
public 'isim' => string 'sinan' (length=5)
public 'yas' => int 31
public 'es' =>
object(stdClass)[3]
public 'isim' => string 'bilge' (length=5)
public 'yas' => int 22
bilge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.