Código PHP:
   
(while)
{
$titulos[$f] = $row ["title"];
              $textos[$f] = $row ["comment"];
          $urls[$f] = $row ["id"];
              $pics[$f] = $row ["image_id"];
              $f++;
 
}
 
Luego abro el script de java 
 
<script>
var text=new Array()
var textlink=new Array()
var texttarget=new Array()
var $b = <?php echo $f; ?>;
 
//Creo un bucle for
 
var $i=0; 
 
for ($i=0;$i<=$b-1;$i++) {
text[$i]="<?php echo $titulos[$i]; ?> <?php echo $textos[$i]; ?>"
document.write($i) 
document.write("<br>") 
}   he puesto el document.write($i) para controlar cuantas veces hace el for y lo hace las 2 veces.
Gracias por vuestra ayuda.
 
 



