2005-09-05, 09:13 PM
2005-09-05, 09:23 PM
" in the wrong places. Try this:
<?
$marlins = "Castillo-|-Pierre-|-Delgado-|-Cabrera";
$doit = explode("-|-",$marlins);
echo "<ul>\n";
foreach($doit AS $point)
{
echo "<li>".$point."</li>\n";
}
echo "</ul>\n";
?>
<?
$marlins = "Castillo-|-Pierre-|-Delgado-|-Cabrera";
$doit = explode("-|-",$marlins);
echo "<ul>\n";
foreach($doit AS $point)
{
echo "<li>".$point."</li>\n";
}
echo "</ul>\n";
?>
2005-09-05, 09:27 PM
You might have to put backslashs at those quotes around <li> And what's with the period before $marlins? If you do that, your script will think that it's a concatenation period with " . $marlins . " ...if you are trying to have a string concatenation then the proper way is:
echo "<li>" . $marlins;
echo "<li>" . $marlins;
2005-09-06, 07:50 AM
If you want to stick with what you've wrote (I'm assuming you are turning an array into a list?)
<?
$marlins=array("Castillo, "Pierre", "Delgado", "Cabrera");
$doit=explode("</li>\n<li>",$marlins);
echo "<li>".$marlins . "</li>";
?>
2005-09-07, 01:32 AM
decswxaqz Wrote:If you want to stick with what you've wrote (I'm assuming you are turning an array into a list?)
<? $marlins=array("Castillo, "Pierre", "Delgado", "Cabrera"); $doit=explode("</li>\n<li>",$marlins); echo "<li>".$marlins . "</li>"; ?>
using implode() would be better for that if you're writing it all into different points on a list
Cory Wrote:You might have to put backslashs at those quotes around <li> And what's with the period before $marlins? If you do that, your script will think that it's a concatenation period with " . $marlins . " ...if you are trying to have a string concatenation then the proper way is:
echo "<li>" . $marlins;
The original one was correct as well. Concatenate a string with a variable, you need a period (dot), but it doesn't matter if there's a space around it or not, it will still work as a concatenation operator. You'll get a parse error if you try to do: echo \"<li>\" . $marlins;
rage Wrote:Whats wrong with this code?
Explode is to separate a string into an array.
Implode is to make a string from an array.