PHP Compressing Strings

by Francis 2012-10-11 18:52:04

To compressing the strings to minimum size and redo the compression
$story ="Can you keep a secret? I had to for a long, long time. My family were all Boxton Town fans, but I supported a different team -- Boxton Rovers.
It was very hard being different. I had to be very good at pretending when both teams played each other.
I could not cheer when my team scored. I had to go to the bathroom and celebrate there.
I could not be sad when the other team scored.
I could only have my team's posters on my bedroom wall when I was alone.
If someone came to my room, I had to be quick to change how it looked.
I had to have a secret wardrobe too. I hid my favourite teams clothes behind the other teams.
Birthdays were terrible too. I always got football gifts for the wrong team. But then my life changed.
A billionaire bought both clubs in my town and made one big team -- Boxton United.
Now I can relax and enjoy all the matches with my family. I go to the bathroom a lot less now too. ";

$compressing = gzcompress($story);

echo "Original size: ". strlen($story)."\n";
Original size: 906

echo "Compressed size: ". strlen($compressing)."\n";
Compressed size: 476

// Uncompressing
$original = gzuncompress($compressing);

You must LOGIN to add comments