Json.parse()表现不同,显然是来自2个不同页面php的相同输入

It's the first time that i ask something here, but this problem seems to me too strange and i have to do it. I had a php code like this:

//Here i take from $_GET

if(isset($_GET["one"])){
        $one= $_GET["one"];
    }
    if(isset($_GET["two"])){
        $two= $_GET["two"];
    }
    if(isset($_GET["three"])){
        $three= $_GET["three"];
    }
//Here i process each variable for the query i want
    if($one== "any"){
        $one= "%";
    }
    else $one= "%".$one."%";
    if($two== "any"){
        $two= "%";
    }
    else $two= $two."%";
    if($three== "any"){
        $three= "%";
    }
    //

    $query = "SELECT one, two, three FROM TABLE WHERE one LIKE ? AND two LIKE ? AND three LIKE ?"

//Here i put "manually" each variable in $params
    $params = [];
    $params_type = "sss";
    $params[0] = $one;
    $params[1] = $two;
    $params[2] = $three;
    echo json_encode(exec_query_header_params($query, $params_type, $params));

For future necessity i wanted to make it more dynamic and I rewrote it like this:

$i=0;
$params = [];
$params_type = "sss";
foreach ($_GET as $key => $value) {
    if(isset($value)){
        if($value == "any")
            $params[$i] = "%";
        else{
            if($key == "one")
                $params[$i] = "%".$value."%";
            elseif($key == "two")
                $params[$i] = $value."%";
            else 
                $params[$i] = $value;
        }
    }
    $i++;
}
echo json_encode(exec_query_header_params($query, $params_type, $params));

Now, the strange thing is that the codes apparently gives me in output the same array, something like this:

[["one","two","three"], //the table-head
,["aaa","bbb","ccc"],   /*
,["aaa","bab","cbc"],     the table-body
,["aaa","bgb","cgc"]]   */

But this ajax request works only with the old code:

var query = 'getter.php?one='+one+'&two='+two+'&three='+three;
$.ajax({type:'GET', url:query, success:takeFromJSON, cache:false, async:false});
//(Inside takeFromJSON there is a call to JSON.parse(data);)

Can anybody explain to me why this happens?