How to Create an Array from a Single Variable and Form Multiple Foreach Loops?
Posted
by matphoto
on Stack Overflow
See other posts from Stack Overflow
or by matphoto
Published on 2010-06-18T01:04:20Z
Indexed on
2010/06/18
1:13 UTC
Read the original article
Hit count: 198
I'm fairly proficient in HTML/CSS, but very new when it comes to the likes of PHP and Javascript. I've jumped headfirst into coding Wordpress shortcodes (basically php functions), and so far, through trial and error and seemingly endless browser refreshes, I've been able to figure everything out. I just hit a huge wall though, hence why I'm here.
Basically, I'm trying to give an attribute a list of values like: attr="23, 95, 136, ect"
The function then needs to take that attribute variable and create an array with it: $arr = array($attr);
To me that seems as if it would work, but the array takes the whole list as one value instead. After doing that I want to create a foreach loop that parses each number from the list, possibly through yet another foreach loop if possible, and returns a section of code for each one, and I'm not quite sure how to pull that off either.
Any feedback would be greatly appreciated.
© Stack Overflow or respective owner