mardi 5 mai 2015

PHP: When searching through an array can't find value at variable

I have never been formally educated in PHP and I am having some issues with traversing an Array in PHP. I was using logic from C++ to go through 2 arrays and checking each slot through a recursive function. The recursive function has been left out because I've found that the issue is in calling a slot with PHP.

The main issue can be simplified in:

$myArray = array(1, 2, 3, 4, 5);
$i = 2;
$printVar = $myArray[$i];

and then $printVar is empty. instead of printing the value 3. I feel like the solution is a simple syntax fix for PHP but I can't find a reference for it anywhere.

Aucun commentaire:

Enregistrer un commentaire