1

Can't figure out for the life of me why this fails. Large PHP array of objects (1200 rows of data) var_dumps just fine. When I json_encode the array, the server fails. code: (without actual large json data)

function generateId() {
    return substr(uniqid ('', true), -5);
}

$obj=(json_decode(utf8_encode($json), true));


foreach ($obj as $value) {
    $newArray[generateId()] = $obj;
}

echo json_encode($newArray);
6
  • 3
    Look at the server logs, especially the error log. 500 errors never go unnoticed, they should leave some traces. Commented Jul 29, 2013 at 21:32
  • Your foreach firstly needs to be $value not $obj Commented Jul 29, 2013 at 21:33
  • What does "fails" mean exactly? Commented Jul 29, 2013 at 21:33
  • You might find this enlightening: stackoverflow.com/questions/6194393/php-json-encode-size-limit Commented Jul 29, 2013 at 21:35
  • Liam answered it... lol... i didn't notice that. Fresh set of eyes always helps, eh? Commented Jul 29, 2013 at 21:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.