Riht now I use array_merge_recursive but if one of my 3 arrays is null I get for echo json_encode($array4);
null
I have 3 arrays in my php file:
$array1 = json_decode($array1, TRUE);
$array2 = json_decode($array2, TRUE);
$array3 = json_decode($array3, TRUE);
If I echo each of the arrays:
echo json_encode($array1); =  {"results":[{"cat_id":2,"cat_name":"bicycle repairs"}]}
echo json_encode($array2); = {"results":[{"cat_id":"4","cat_name":"plumber"},{"cat_id":"5","cat_name":"Electrician"},{"cat_id":"6","cat_name":"vet"}]}
echo json_encode($array3);= {"results":[{"cat_id":3,"cat_name":"Doctor"}]}
And then I merge these arrays together like this:
$array4 = array_merge_recursive($array1['results'], $array2['results'], $array3['results']);
Which would give me:
[{"cat_id":2,"cat_name":"bicycle repairs"},{"cat_id":"4","cat_name":"plumber"},{"cat_id":"5","cat_name":"Electrician"},{"cat_id":"6","cat_name":"vet"},{"cat_id":3,"cat_name":"Doctor"}]
But if any of $array1, $array2 or $array3 is null then $array4 doesn't work. How can I overcome this?