Jump to content

in_array help


dink87522

Recommended Posts

My code on one page is:

$_SESSION['q20'] = $countries[$rndWork]."D".$answer."D".$answer_result;

 

and on the next page is:

$q20 = $_SESSION['q20'];
for ($i = 0; $i < 3; $i = $i + 1){
$q20Split = array_slice(explode("D", $q20), i, 1);
$question20[i] = $q20Split; 
} ?>

 

however I get the following error which I have never seen before:

 

Warning: array_slice() expects parameter 2 to be long, string given in /home/public_html/geographytrainer.com/hsDis.php on line 31

 

Warning: array_slice() expects parameter 2 to be long, string given in /home/public_html/geographytrainer.com/hsDis.php on line 31

 

Warning: array_slice() expects parameter 2 to be long, string given in /home/public_html/geographytrainer.com/hsDis.php on line 31

Link to comment
https://forums.phpfreaks.com/topic/186558-in_array-help/
Share on other sites

$q20 = $_SESSION['q20'];
echo("q2a: $q20");
for ($i = 0; $i < 3; $i = $i + 1){
$q20Split = array_slice(explode("D", $q20), $i, 1);
$question20[i] = $q20Split; 
} 
echo("q0: ".$question20[0]);
echo("q1: ".$question20[1]);
echo("q2: ".$question20[2]);

 

q2a prints "GrenadaDSt. George'sD0"

q0, 1, 2 do nit print.

Link to comment
https://forums.phpfreaks.com/topic/186558-in_array-help/#findComment-985240
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.