This code:
$arr = array(
'a' => 1,
'b' => array(
'c' => 'Hello',
'd' => [1, 10, 100, 1001]
),
);
echo json_encode($arr, JSON_PRETTY_PRINT, 2);
Generates this error:
json_encode() expects at most 2 parameters, 3 given
However the last time I checked, json_encode does accept a 3rd argument.
I want to expand the JSON string by less depths. Ain't the 3rd the solution here? But why does it give this error while PHP doc says it accepts 3?
FYI I'm on WAMP with PHP 5.4.
depthparameter was added in php5.5. It's written in the documentation.