I need to add some sort of line break after each segment (date, name, address, phone) to separate them, I have tried using the break and paragraph etc but just keep on getting syntax errors with the usual unexpected "<" and have also tried using tables but that failed too.
Is there an easy way to format the output of this to display each part on a separate line please?
<?php
$file = file_get_contents('http://somesite.com/Data/jsontxt');
$out = (json_decode($file));
echo $out->date;
echo $out->name;
echo $out->address;
echo $out->phone;
?>
This is a sample of the array:
{
"name":"Joe Bloggs",
"date":"11:58pm 28 August 2010",
"address":"13 Boggy Ave, Hamilton",
"phone":"555-5478"
}
and what I am currently getting:
Joe Bloggs11:58开发者_JAVA百科pm 28 August 201013 Boggy Ave, Hamilton555-5478
Use this code:
<?php
$file = file_get_contents('http://somesite.com/Data/jsontxt');
$out = (json_decode($file));
echo $out->date . '<br/>';
echo $out->name . '<br/>';
echo $out->address . '<br/>';
echo $out->phone . '<br/>';
?>
You have to break the PHP block in order to output.
<?php
foo();
?>
All mimsy were the borogoves, and the mome raths outgrabe.
<?php
bar();
?>
精彩评论