Using (or massacring) PHP, I'm trying to read the contents of a text field in a database (magazine article) and then break it into lines and insert an image file ever 3-4 lines if the image is specified (lower down).
The code I'm using to do this is the following:
[PHP]
$picnum = 0;
$picsplits = 3;
$i=0;
foreach ($revText as $para) {
if (fmod($i,$picsplits) != 0) {
$newText .= $para . "<br /><br />";
} else {
//$newText .= $para . fmod($i,$picsplits) . '<br />';
$newText .= $para . $photos[$picnum] . '*<br /><br />';
$picnum++;
}
$i++;
}
[/PHP]
Each entry also contains 6 fields called photo1 through photo6 which can be filled in starting from the first up until as many photos are needed for the article. I've managed to get these into an array using this code:
[PHP]
$pnum = 2;
$phot = "";
while ($pnum < 7) {
$pcol = "photo" . $pnum;
if ($row_rsArticle[$pcol] != "") {
$phot .= '"' . $row_rsArticle[$pcol] . '",';
}
$pnum++;
}
$photos = explode(",",$phot);[/PHP]
Now I would think that the array $photos is defined in this code so that I should be able to refer to it later on in the bit of code at the beginning of this message which adds the image to the output. However, this is sadly not happening.
I realize I have to still add the <img src etc.. but I think that is the easier part. I also did in fact print out $photos and it IS indeed OK and prints fine when not used in the function for outputting the text and images.
It's just inside the foreach loop that it's not working...
Help please?