this might be quite a dummy question. I've been searching the web and trying around alot but i just can't find a solution.
I am sending out Core Data Objects as Dictionarys within an Array to my PHP JSON RPC web service. I will not dig further into this at this point, because i know that my JSON RPC is well formed.
On PHP side i do have one RPC Server which will take the JSON data and pass it to the respective function.
$request = json_decode(file_get_contents('php://input'),true);
Using print_r i get the following result
print_r($request['params']);
(Sorry, i don't know how to include 'Array (' and the closing ')' in the box)
Array
(
[0] => Array
(
[dayId] => 7
[dayName] => Sonntag
)
[1] => Array
(
[dayId] => 6
[dayName] => Samstag
)
[2] => Array
(
[dayId] => 4
[dayName] => Donnerstag
)
[3] => Array
(
[dayId] => 2
[dayName] => Dienstag
)
[4] => Array
(
[dayId] => 1
[dayName] => Montag
)
)
As mentioned before, this array is now passed to the respective function using
$result = @call_user_func_array(array($object,$request['method']),$request['params']))
This will call method updateDaysFromClient in my implementation class. At this point, i would like to repeat, that my JSON RPC is well formed (method, id, params).
public function updateDaysFromClient($clientDaysArray) {
print_r($clientDaysArray);
return "Update test";
}
Now comes my problem: Within my implementation, when calling the print_r on the array passed as parameter, i will only receive the first element of that array.
Array (
[dayId] => 7
[dayName] => Sonntag
)
Can anyone explain to me why not the whole Array but only the first element is passed?
Please try to pass like this,
$result = @call_user_func_array(array($object,$request['method']),array($request['params'])))
pass $request['params'] inside another array.