Re: Seperate strings in PHP

From: Date: Tue, 02 Jan 2001 20:54:48 +0000
Subject: Re: Seperate strings in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-32347@lists.php.net to get a copy of this message
Consider explode : PHP Manual : explode() ---------------------------------------------- http://www.php.net/manual/function.explode.php $string = 'ac,pw,ps,rc'; $features = explode(',',$string); foreach ($features as $feature) { print '<img src="images/'.$feature.'.gif">'; } Which will print all the images. regards, philip On Mon, 1 Jan 2001, Sefton wrote: > Hello Everybody, > > Happy New Year !!! > > I have a question that to the skilled is probably very basic. > > Within a mysql database I have a field that holds the following type of > information... > > ac,pw,ps,rc,cd,aw,rs,4wd,abs etc > > It is the features of a car, and the field name is "specs" (Eg ac = air > conditioning, pw = power steer etc) > I don't want an indivual field for all the different features, but I want to > be able to break up the above string and place an image in my page for that > abreviation. I have the rest sorted out the vehicle make model etc I just > need to display these. I already have the images (eg: ac.gif) > Different vehicles will have different numbers of specs. Some might only > have ac,pw,ps. > > Example > I would like the above string to appear something like... > echo "<img src=\"images/$myrow[10].gif\">"; > > I am not sure how to continue it. Let alone split the string. I assume > converting the string to an array would work, but I am not sure how. Is > there an opposite to the implode command where I could specify the "," as a > break? > > Any help would be really great. > > Thanks, > > Chris > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#32347) next »