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
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?" 

 

 

Link to comment
Share on other sites

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');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.