Skip to content

Instantly share code, notes, and snippets.

@Bolinha1
Created October 30, 2013 12:21
Show Gist options
  • Select an option

  • Save Bolinha1/7231742 to your computer and use it in GitHub Desktop.

Select an option

Save Bolinha1/7231742 to your computer and use it in GitHub Desktop.
Json
<?php
$json = file_get_contents('http://localhost/json/json.php'); // só alterei o caminho
$obj = json_decode($json);
var_dump($obj);
print_r($obj);
/*
var_dump
object(stdClass)#1 (4) {
["locutor"]=>
string(4) "Joke"
["programa"]=>
string(5) "J-MIX"
["musica"]=>
string(26) "Asian Kung Fu - Generation"
["ouvintes"]=>
string(1) "4"
}
print_r
stdClass Object
(
[locutor] => Joke
[programa] => J-MIX
[musica] => Asian Kung Fu - Generation
[ouvintes] => 4
)
*/
<?php
header('Content-Type: application/json');
$json = array(
'locutor'=>'Joke',
'programa'=>'J-MIX',
'musica'=>'Asian Kung Fu - Generation',
'ouvintes'=>'4'
);
print json_encode($json);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment