I'm very new to PHP, so I'm probably missing something very obvious here, but I just can't figure it out.
function get_halfway_index($position, $size) {
for($i = 0; $i < ($size / 2); $i++){
if ($position == $size){
$position = 0;
} else {
$position++;
}
}
echo "returning " . $position . "<br>";
return $potition;
}
echo "value returned: " . get_halfway_index(0, 500) . "<br>";
I have a function, get_halfway_index
, that does some stuff and is supposed to return $potition
at the end. I print the value before returning it, and it prints the right value- so no problem there. But when I try calling the function, nothing gets returned.
The output is
returning 250
value returned: