Jump to content

Explode Spilt & Arrays


Recommended Posts

Hey Guys,

 

I've got this code:

while($row = mysql_fetch_array($result))
	{
		 $tagstringarray[]=$row['mycolumn'];

	}
 }

 foreach ($tagstringarray as $tag) {
	$pieces[] = explode(",", $tag);
 }

  foreach ($pieces as $tag) {
	echo $tag . "<br/>";
 }
	print_r ($pieces);

 

My database has a number of records which are tags, so are seperated by commas. eg. "tag1, tag2, tag3", but some just contain 1 tag eg "tag1".

 

This seems to put it as (presumably) a multi dimensional array, any ideas how I can return it all to one single dimensional array?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/202147-explode-spilt-arrays/
Share on other sites

Why would you swap one for the other? If you don't wan't to explode this string, just don't use explode...

 

while($row = mysql_fetch_array($result)) {
  $tagstringarray[]=$row['mycolumn'];
}

foreach ($tagstringarray as $tag) {
  echo $tag."<br/>";
}

Archived

This topic is now archived and is closed to further replies.

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