• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

Create Array Based on Delimiter

I have a line that will output like this:

apples oranges peaches bread

I want to be able to use the values as an array based on the space delimiter " ".

printf($array[0]);
printf($array[2]);

The above prints should output something like this: apples oranges

I'm way off; I know; but hope you can help.
0
deharvy
Asked:
deharvy
  • 2
1 Solution
 
alien109Commented:
$array = explode("apples oranges peaches bread", " ");
0
 
alien109Commented:
oops clicked submit before I wanted. It's actually reversed from that :) sorry.

$array = explode("", "apples oranges peaches bread");
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now