Having an issue here. When I attempt to do this:
foreach ($validation_fields as $val) {
$rule = json_decode($val['rules'], true);
$key = 'fields[' . $val['group_id'] . '][' . $val['field_id'] . ']';
if (array_key_exists($key, $rules)) {
array_merge($rules[$key], $rule);
}
}
PHP throws an error back at me saying that argument 2 is not an array, however, when I dump $rule or use is_array($rule), it checks out as being an array. I am so confused.
the json I am decoding is:
'{"format": {"rule": ["matches","/[0-9]{9}/"], "negate": true,"message": "Apps"}}'
var_dump(json_decode($rule)) is:
array
'format' =>
array
'rule' =>
array
0 => string 'matches' (length=7)
1 => string '/[0-9]{9}/' (length=10)
'negate' => boolean true
'message' => string 'Apps' (length=30)
array_merge() [function.array-merge]: Argument #2 is not an array on line 197 in ....