Hi,

I need some code that will get a string and turn each part thats seperated by a comma into a link:

e.g.

$string = "page2,page15, page91, page, page32";

<code here>

then the output as html will be like this:
<a href="/site/page2.php">Go page2</a> <br> <a href="/site/page15.php">Go page15</a> <br> <a href="/site/page91.php">Go page91</a> <br>

etc

so somekind of code that gets all the letters before the first comma and puts it into the link

Any way i can do this?? Thanks

Hedcase. Community and dating

    Adapt this code:

    $string = "page2,page15, page91, page, page32";
    $array = explode(',', $string);
    foreach ($array as $value) {
    	$value = trim($value);
    	echo '<a href="/site/' . $value . '.php">Go ' . $value . '</a><br>';
    }

      Ah, Thankyou!!!

      Ive been searching for ages to get this done! noticed alot of your posts for string manipulation but non i could use b4. this works great!

      http://www.hedcase.co.uk

        Write a Reply...