1

i'm trying to receive a response from an url as :

$result = file_get_contents('http://example.com/api/test');

it simply returns some informations separated by | example :

info1|info2|info3

i want to get that result as an array

something like $result = array(file_get_contents('http://example.com/api/test'));

I just got involved in php stuffs excuse me for any confusing terms !

2
  • 1
    google php explode Commented Apr 24, 2017 at 23:26
  • Take that string and use explode() to turn it into an array. Here is a link: php.net/manual/en/function.explode.php Commented Apr 24, 2017 at 23:27

3 Answers 3

1

i just got it !

explode("|",$result);
Sign up to request clarification or add additional context in comments.

1 Comment

Next time, search before you post.
1

Very simple to do:

$resultArray = explode("|", $result);

Comments

0

You can use explode() to separate the data by pipe.

$result = explode('|',file_get_contents('http://example.com/api/test'))

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.