What’s Wrong
You’re trying to use a “variable variable” by building a variable name from two pieces, split
and $i
. This is not usually the best way to do things, and you’re doing it incorrectly.
$split($i)
doesn’t mean “the variable named ‘split and the value of $i
.'” It means, “take a variable named $split
, treat its value as a function, and call that function with a parameter of $i
.”
How to “Fix” It
If you really want to use variable variables, your syntax needs to be this:
${'split' . $i}
Again, this is a bad idea. You really should use an array instead.
How to Do It a Better Way
Use an array, as in
$split[1] = 1;
$split[2] = 2;
...
Then refer to the values as $split[$i]
for whatever (valid) values of $i
.
solved PHP Fatal error: Trying to compare `if ($row[‘distance_name’]==$split($i)`