Instead of using json_encode()/json_decode(), use serialize()/unserialize(). The latter allows you to do things like transfer PHP objects intact across hosts while JSON is more limited. If you are transferring data from a database, I recommend doing:
PHP Code:
echo base64_encode(serialize($row)) . "\n";
On the source and this:
PHP Code:
$lines = explode("\n", file_get_contents("sourceurlhere"));
foreach ($lines as $line)
{
$row = unserialize(base64_decode(trim($line)));
...
}
For the destination. That's the fastest, easiest way to get data to cross from one PHP host to another on a temporary basis (e.g. a data migration export/import script set for a redesigned web app). You wouldn't want to do this sort of thing for anything other than a quick-n-dirty script that will be used just once or twice - otherwise you'll create a maintenance nightmare in short order.
Bookmarks