Page 1 of 1

use while and statement For String

Posted: Wed Jun 10, 2009 4:28 am
by zboy2
Hi all
please help me About this qouestin :

my string for example is :
$string = "name door pic other"; //(my string is random because retrieve from DB and have Space [mysql filed = text])
I want Detachment $string in output and every Word [exam : name or other] have a link
i think i must use explode , and while for this string..
I need this output :

name door pic and....

(actually i want create news tag and every tag need a link)

Re: use while and statement For String

Posted: Wed Jun 10, 2009 4:58 am
by globezone
try this...

Code: Select all

 
$a = "name door pic other";
 
$b = explode(" ", $a);
 
for($i=0; $i < count($b); $i++)
{
    echo '<a href="#'.$b[$i].'"> '.$b[$i].' </a>';
}
 

Re: use while and statement For String

Posted: Wed Jun 10, 2009 5:29 am
by zboy2
Prefect 8O , thank your so much