[web] PHP problem - logical code isn't working...

Started by
1 comment, last by Sander 19 years, 3 months ago
Hey everyone, I have been trying to get this to work for ever and I'm totally stuck. Here's my code below

$pgdesc_track = ($pgdesc_track + 1);
$pgdesc[$pgdesc_track2] = str_replace("<DRS::DATETIME>", "date test", $pgdesc[$pgdesc_track]);
$pgdesc_track2 = ($pgdesc_track2 + 1);
echo "$pgdesc_track<br />";
echo "$pgdesc_track2<br />";
echo "$pgdesc[$pgdesc_track2]";

It won't display $pgdesc[$pgdesc_track2] after I go thorugh the str_replace function. Can someone please point out to me what I'm doing wrong? I'm sure it's somthing simple but I just can't see it. Any help is appreciated.
Advertisement
really what I'm trying to accomplish is replace this string unlimited times through this method.
echo "$pgdesc[$pgdesc_track2]";

should be

echo $pgdesc[$pgdesc_track2];

I think. That's because PHP assumes quotes around the array field when inside a string. When readinging your echo string it interprets it as $pgdesc["$pgdesc_track2"] which doesn't exist and therefor returns empty.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement