Start New Discussion within our Web Development Community

Hi everyone

echo '<script language="javascript">
var dA = new Array();
var x = 0;


	dA[x++]="'.$date[$i]." ".$message[$i].'";


here i want to increment $i above code is not working, Please help...Thanks in Advance...

You can't execute a client side(javascript) for loop on the server side(php). You can print javascript out incrementally that would be an array of size 2 using a for loop on your server side. For instance:

$i = 0;
echo '<script type=text/javascript>';
echo 'var dA = new Array();';
for ($i = 0; $i < 2; $i++)
    echo 'dA['.$i.'] = "'.$date[$i].$message[$i].'";';
echo '</script>';
This article has been dead for over six months. Start a new discussion instead.