Re: Making an Unordered List?
| From: | Dean Hall | Date: | Thu, 24 Aug 2000 21:02:03 +0000 |
| Subject: | Re: Making an Unordered List? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-13523@lists.php.net to get a copy of this message | ||
> Item: soda
> Item_Descritpion: sweet~low in sodium~100 calories per serving~carbonated
>
> I want to be able to output this as:
>
> soda
> * sweet
> * low in sodium
> * 100 calories per serving
> * carbonated
>
> ...Now the question... How do I get PHP/PostgreSQL to replace each "~" with
> "<LI>", and just output all of the other text as-is? Each "Item" has
> a
> varying amount of points to display, so I can not depend on a constant
> number of "~" characters being encountered for each of them.
Use str_replace.
If your string containing the Item_Description is $item_description, do
this (untested):
str_replace("~", "</LI>\n<LI>", $item_description);
?>
<p><?=$item?><br>
<UL>
<LI><?=$item_description?></LI>
</UL>
</p>
This actually does more than you want -- it keeps your <LI> tags closed as
well -- you shouldn't let them hang like that without closing them.
Dean.