Store looped data in separate variables?

thePrado

New Member
I'm currently using the following in my \[code\]single.php\[/code\] file to list the parent category and child category that my posts belong to:\[code\]foreach((get_the_category()) as $category) { echo '<h1>'.$category->cat_name . '</h1>'; }\[/code\]So this results in:\[code\]<h1>Events</h1><h1>News</h1>\[/code\]However, I would like to store each \[code\]<h1>\[/code\] value in a separate variable.So my eventual code could be:\[code\]$i1 = "<h1>Events</h1>"; $i2 = "<h1>News</h1>";\[/code\]How do I do this?Many thanks for any help with this.
 
Back
Top