I want to write and pass array index value in string to another php file. Kindly check what I am doing:
<?php
$pages = array("Story1","Story2","Story3");
$fp = fopen('urls.php', 'w');
for($i=0;$i<$length;$i++){
fwrite($fp, '<a href="kids-{$pages[$i]}">Kids App Stories</a><br>');
}
fclose($fp);
?>
I am having problem below line:
fwrite($fp, '<a href="kids-{$pages[$i]}">Kids Stories</a><br>');
The above line write as it is in urls.php
<a href="kids-**{$pages[$i]}**">Kids Stories</a><br>
<a href="kids-**{$pages[$i]}**">Kids Stories</a><br>
<a href="kids-**{$pages[$i]}**">Kids Stories</a><br>
While I am expecting the output:
<a href="kids-story1">Kids Stories</a><br>
<a href="kids-story2">Kids Stories</a><br>
<a href="kids-story3">Kids Stories</a><br>
I want in urls story1,story2,story3 instead of {$pages[$i]}
Any idea or suggestions would be welcome.
");` – arkascha Oct 09 '18 at 06:42
');` – Mark Vincent Manjac Oct 09 '18 at 06:44