-3

Is it possible to put the results from an array into a string?

     <? foreach($get->artist->tags->tag as $tags) {
    $tags = (array) $tags;?>

 <? echo $tags['name'];?>

    <?}?>   

is it possible to also make a string that seperates all of $tagsnames with commas?

For example let's say the tags are

House Electronic Pop R&B

Is it possible to create a string like this

$mystring = House,Electronic,Pop,R&B

thanks

UPDATE :

$laststation = implode(',', array_column($get->artist->tags->tag, 'name'));
$laststation = addslashes($laststation);
$laststation_array = explode(',', $laststation);
$laststation_search = implode("%' OR `tags` LIKE '%", $laststation_array);

$query5 = mysql_query ( "SELECT * FROM `Stations` WHERE `tags` LIKE '%".$laststation_search."%' AND `status` = 'Online'  ORDER BY RAND() LIMIT 8" );

I have tried using implode as above, but does not seem to be giving any results back.

2 Answers2

1

As you can increment numbers with:

$var++;

or

$var += 1;

You can also add stuff to string:

$string = 'pizza';

$string .= ", hamburger";

Or as well you can use implode()

KeyBi
  • 140
  • 5
0

I think you want the implode command. It takes an array and glues it together into a string.

http://php.net/manual/en/function.implode.php

Perry Bird
  • 33
  • 4