0

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:58pm 28 August 201013 Boggy Ave, Hamilton555-5478

2 Answers 2

2

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/>';
?>
Sign up to request clarification or add additional context in comments.

Comments

1

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();
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.