使用php将数组转换为字符串ready ajax data filter

Can the following array be converted into the string below...

$eventsfilters = array(
    'language' => $languagePath,
    'page' => 1, 
    'limit' => 9, 
    'start_date' => time()
);

into this:

$ajax_filter = "'language': '" . $languagePath . "', 'page': 1, 'limit': 9, 'start_date': " . time();

This will then go into an ajax data filter.

Just try with below code :

$eventsfilters = array(
    'language' => "sdfsd",
    'page' => 1, 
    'limit' => 9, 
    'start_date' => time()
);

foreach($eventsfilters as $key => $val){
    $arr[] = "'$key':".$val; 
}

$arr = implode(",", $arr);

echo $arr;

If it is going through an AJAX filter it will probably need to be in a JSON format. The string you posted is not valid json. It is best to just pass the array into json_encode.

$ajax_filter = json_encode($eventsfilters);

Which would return something like this:

{"language":"languagePath","page":1,"limit":9,"start_date":1412241074}