this is the part of code where I have problem!
$names = array('Donald', 'April', 'Adel');
$age = array('56', '16', '23');
$city = array('New York', 'Erie', 'Rabat');
$records = array('name' => $names, 'age' => $age, 'city' => $city);
$to_loop = '<li>My name is <!--name-->, I am a <!--age--> years old, I live in <!--city--> city';
$keys = array_keys($records);
for ($i = 0; $i < 1; $i++)
{
for ($x = 0; $x < count($records[$keys[$i]]); $x++)
{
for ($y = 0; $y < count($keys); $y++)
{
$loops.= str_replace('<!--' .$keys[$y]. '-->', $records[$keys[$y]][$x], $to_loop);
}
}
}
print($loops);
code above should print something like this:
<li>My name is Donald, I am a 56 years old, I live in New York city.
and so on... but what I got this:
<li>My name is Donald, I am a <!--age--> years old, I live in <!--city--> city.
<li>My name is <!--name-->, I am a 56 years old, I live in <!--city--> city.
<li>My name is <!--name-->, I am a <!--age--> years old, I live in New York city.
and so on!
where I did the mistake?
please help