create array with predefined $values

Started by Kender, March 02, 2008, 04:03:45 AM

Previous topic - Next topic

Kender

okay, here it is, simple

$arrvalue = "1,2,3,4,5";
$array = array($arrvalue);
print_r($array);


outputsArray (
  [0] => 1,2,3,4,5
)
How do i make it treat each seperate value as a new array item (seperated by comma)Array (
  [0] => 1,
  [1] => 2,
  [2] => 3,
  [3] => 4,
  [4] => 5
)
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Joshua Dickerson

Put in to geek speak: you have a comma delimited list that you want split up by the commas in to an array. explode()
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Kender

if i explode at the , wont it just give me...

Array (
  [0] = > 1 2 3 4 5
)


without the comma ?

i guess im asking for a more defined help... ie, where do i put the explode statement, etc
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Joshua Dickerson

Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

Kender

*eats crow*

thanks for pointing that out.. I have used explode many times to create an array and never thought of using it in this instance
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Advertisement: