I'm rather new to PHP and would need help with the following:
I have data in a field that is read and displayed as individual links (1 link per line break) on my web page.
Before displaying the links on my page, I needed to replace the underscores of their related files with slashes and so.
The links display appropriately. My problem is when I link these to each line in the field the ahref considers all the text as one big link and does not consider the line breaks as "separators".
Here's my chunk of code:
// READ EACH LINE IN FIELD AS INDIVIDUAL link
$array_chapters=explode("\r\n", $prod_chapters);
foreach($prod_chapters as $key => $value) {
if($value == "") {
unset($prod_chapters[$key]);
}
}
// REPLACE UNDERSCORES AND 'and' with SPACES AND SLASHES IN ARRAY
//to display the links appropriately
$array_chapters=str_replace(".."," ",$array_chapters);
$array_chapters=str_replace("and_","/",$array_chapters);
//DISPLAY array of LINKS and link to individual file by the same name (but with the
//underscores and such). This all works fine except that it reads each line as one
//big link
$array_chapters_lenght=sizeof($array_chapters);
$z=0;
while($z<$array_chapters_lenght){
echo '<img src="images/products/icon_purple_arrow.gif" alt="" align=right hspace=10 valign=middle>';
echo '<a href="product.php?i='.$i.'&l='.$l.'&chapter='.$prod_chapters.'">';
echo '<font color="'.${$array_chapters[$z]."_color"}.'">'.$array_chapters[$z].'</font></a><hr size=1 color=#cccccc width=170 align=left>';
$z++;
}
//Any way to get this to read (prod_chapters) as one line per link ?
Thanks for your help