array( 'a' => 'a', 'b' => 'b' ), 'test' => pi() ); // Now test with serialize() print 'serialize() ...' . PHP_EOL; $time = microtime(true); for ($idx = 0; $idx < $iter; $idx++) { $serialized = serialize($array); } $diff1 = microtime(true) - $time; // Now test with json_encode() print 'json_encode() ...' . PHP_EOL; $time = microtime(true); for ($idx = 0; $idx < $iter; $idx++) { $json_encoded = json_encode($array); } $diff2 = microtime(true) - $time; print 'diff1=' . $diff1 . ',diff2=' . $diff2 . PHP_EOL;