3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function buildNvpair($name, $value) { $nlen = strlen($name); $vlen = strlen($value); if ($nlen < 128) { /* nameLengthB0 */ $nvpair = chr($nlen); } else { /* nameLengthB3 & nameLengthB2 & nameLengthB1 & nameLengthB0 */ $nvpair = chr(($nlen >> 24) | 0x80) . chr(($nlen >> 16) & 0xFF) . chr(($nlen >> 8) & 0xFF) . chr($nlen & 0xFF); } if ($vlen < 128) { /* valueLengthB0 */ $nvpair .= chr($vlen); } else { /* valueLengthB3 & valueLengthB2 & valueLengthB1 & valueLengthB0 */ $nvpair .= chr(($vlen >> 24) | 0x80) . chr(($vlen >> 16) & 0xFF) . chr(($vlen >> 8) & 0xFF) . chr($vlen & 0xFF); } /* nameData & valueData */ return $nvpair . $name . $value; } $a = buildNvpair("keyword", "48260,49404,49412,49452,49454,49504,49539,49559,49609,49615,49616,49617,49618,49639,49688,49689,49691,49692,49696,49704,49724,49766,49767,49768,49769,49771,49772,49814,49857,49858,49861,49862,49863,49864,50544,50588,50617,50653,50665,50666,50667,50668,50669,50670,50671,50672,50673,50674,50675,50730,50731,50732,50733,50735,50736,50737,50750,50753,50754,50786,50788,50790,50800,50900,50901,50902,50903,50904,50905,50906,50907,50908,50909,50920,50921,50922,50923,50924,50925,50944,50979,50985,50987,50990,51101,51102,51103,51104,51105,51106,51107,51108,51109,51110,51111,51112,51113,51114,51115,51121"); var_dump($a);
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(611) "�Wkeyword48260,49404,49412,49452,49454,49504,49539,49559,49609,49615,49616,49617,49618,49639,49688,49689,49691,49692,49696,49704,49724,49766,49767,49768,49769,49771,49772,49814,49857,49858,49861,49862,49863,49864,50544,50588,50617,50653,50665,50666,50667,50668,50669,50670,50671,50672,50673,50674,50675,50730,50731,50732,50733,50735,50736,50737,50750,50753,50754,50786,50788,50790,50800,50900,50901,50902,50903,50904,50905,50906,50907,50908,50909,50920,50921,50922,50923,50924,50925,50944,50979,50985,50987,50990,51101,51102,51103,51104,51105,51106,51107,51108,51109,51110,51111,51112,51113,51114,51115,51121"