foreach例程向数组添加变量的问题

When calling the function below and passing the parameters "test/asdf" for $url and "variables" for $element, the foreach routine doesn't add the variable $var to the $variables array. However, the routine correctly prints out the $var value.

public function ParseURL($url, $element)
    {
        $splitURL = preg_split("/(\\/)/is", $url);
        if ($element == "page_id"){return $splitURL[0];}
        elseif ($element == "all"){return $splitURL;}
        elseif ($element == "variables"){
            $i = 1;
            $variables = array(0 => "test");
            foreach ($splitURL as $var) {
                if ($var != $splitURL[0]){
                    $variables[$i] == $var;
                    echo $var;
                    echo $variables[$i];
                    $i++;
                }
            }
            var_dump($variables);
            return $variables;
        }
    }

Edit

The input URL would be everything after the domain of a webpage, so if you inputted the string example.com/function/variable/variable2, it would return either "function", an array containing "function", variable and variable2 or an array containing "variable" and "variable" based on the string inputted into the element parameter.

The expected output is an array of variable and variable2.

You have a typo in the assignment, in your example, theres a double ==:

$variables[$i] == $var;
               ^^

You probably wanted to write only one

change $variables[$i] == $var; to $variables[$i] = $var;