Jump to content

Explode String and Use as Array?


chaseman

Recommended Posts

I have in ONE MySQL database row a string of ID's like this:

 

Name of Row:Values:

Post IDs10 14 52 37

 

And now I want to fetch those ID's explode them (by the space) and then use them as an array, like this:

 

$array[] = explode(" ", $query);

echo $array[0]; // 10
echo $array[1]; // 14
echo $array[2]; // 52

 

Is this possible, if yes how can I do this?

Link to comment
https://forums.phpfreaks.com/topic/233760-explode-string-and-use-as-array/
Share on other sites

Confusion was that I had the brackets around it thinking that would be the correct way, and ken corrected me. Besides that I like posting new threads, and I posted this for the sake of it.

 

The last part was sarcasm, the first part was true.

 

You would help everyone out including yourself, if you did a better job describing your problem.  Yes you had the wrong syntax, but your question didn't indicate that you'd tried anything and had a problem-- instead it asked: "How do I do this?" 

 

 

My question was clear enough for the first poster to answer it with ease.

 

I really didn't know how to do this, because I have never done it before. So what would be the obvious choice here? To simply ask how to do it.

 

This not a why isn't it working question.

 

die ('Have a nice day');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.