I am trying to use an editable table and have it working except for when the array values passed to the save function contain double quotes. The error occurs at foreach loop
foreach($saveArray as $rowId=>$row) {
It is the values (not keys) which may contain double quotes, the actual error being:
Warning: Invalid argument supplied for foreach()
What is the best way around this, some way to escape them, change them to the " code, change the way the loop works?
EDIT:
Sorry, the problem is actually with the json_decode function and double quote values, not returning an array.
Works fine for non double quoted entries
json looks like
{"2":{"component":"8\"", ...
So it is escaped but it’s not decoding into an array
See what
$saveArrayactually is, usingIt doesn’t look like your
$saveArray, whatever it is, supports theforeachconstruct.If
$saveArraycomes fromjson_decode(), it’s likely that your JSON string is invalid, andjson_decode()just returnsNULL.