use while and statement For String

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zboy2
Forum Newbie
Posts: 2
Joined: Wed Jun 10, 2009 4:13 am

use while and statement For String

Post 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)
globezone
Forum Newbie
Posts: 7
Joined: Wed Jun 10, 2009 4:57 am

Re: use while and statement For String

Post 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>';
}
 
Last edited by globezone on Sun Jun 14, 2009 4:53 am, edited 1 time in total.
zboy2
Forum Newbie
Posts: 2
Joined: Wed Jun 10, 2009 4:13 am

Re: use while and statement For String

Post by zboy2 »

Prefect 8O , thank your so much
Post Reply