I have this code on my WAMP server running on my XP machine
if ( isset( $_POST[ 'ans' ] ) )
{
for($i=0; $i<count($_POST['ans']);$i++)
{
if ($ans != NULL )
$ans .= ", " . $_POST['ans'][$i] ; // Not the first
element so append a comma
else
$ans = $_POST['ans'][$i] ; // first element so comma
not needed
}
echo 'answer is '. $ans . '<br>';
}
The purpose of the for loop is to concatenate all the elements into a comma
seperated string.
It works fine so if the first element is 22/7 it prints 'answer is 22/7'
However when I upload the file to the actual Linux based server and run the
same I get 'answer is Array, 22/7'. Here the word 'Array' is given as the
first element. So what's wrong and how can I fix this.
Thanks.
if ( isset( $_POST[ 'ans' ] ) )
{
for($i=0; $i<count($_POST['ans']);$i++)
{
if ($ans != NULL )
$ans .= ", " . $_POST['ans'][$i] ; // Not the first
element so append a comma
else
$ans = $_POST['ans'][$i] ; // first element so comma
not needed
}
echo 'answer is '. $ans . '<br>';
}
The purpose of the for loop is to concatenate all the elements into a comma
seperated string.
It works fine so if the first element is 22/7 it prints 'answer is 22/7'
However when I upload the file to the actual Linux based server and run the
same I get 'answer is Array, 22/7'. Here the word 'Array' is given as the
first element. So what's wrong and how can I fix this.
Thanks.
Comment