The code below worked correctly in PHP 7.0, but after upgrading to 7.3 it now gives this warning:
PHP Warning: Illegal string offset on line 71
// Loop through routes
$array_result = "";
$array_index_result = "";
foreach($routes as $key => $route){
$route_parts = explode("/", $route);
$index = 0;
$match = TRUE;
// Reset array_result
$array_result = "";
foreach($route_parts as $route_part)
{
if(substr($route_part,0,1) != "$"){
if(isset($url_parts[$index])){
if($route_parts[$index]!=$url_parts[$index]) $match = FALSE;
}else{
$match = FALSE;
}
}else{
if(isset($url_parts[$index])){
$array_result[substr($route_parts[$index],1)] = $url_parts[$index];
}
}
if(isset($url_parts[$index])){
$array_index_result[$index] = $url_parts[$index];
$index++;
}
}
if($match && (count($route_parts) == count($url_parts)))
{
$Info = new ModRewriteInfo($array_result, $array_index_result);
return $Info;
}
}
// No match found
return FALSE;
Line 71 is
$array_result[substr($route_parts[$index],1)] = $url_parts[$index];
The code runs on PHP 7.0 but not in PHP 7.3. Why is that?