3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function ved_decode($ved) { /* // Copyright 2013 Deed Poll Office Ltd, UK <https://deedpolloffice.com> // Licensed under Apache Licence v2.0 <http://apache.org/licenses/LICENSE-2.0> $keys = array('t' => 2, 'r' => 6, 's' => 7, 'i' => 1); $ret = array(); if (substr($ved, 0, 1) == '1') { preg_match_all('/([a-z]+):([0-9]+)/i', $ved, $matches, PREG_SET_ORDER); foreach ($matches as $m) $ret[isset($keys[$m[1]]) ? $keys[$m[1]] : $m[1]] = (int) $m[2]; return $ret; } */ preg_match_all('/([\x80-\xff]*[\0-\x7f])([\x80-\xff]*[\0-\x7f])/', base64_decode(str_replace(array('_','-'), array('+','/'), substr($ved, 1))), $matches, PREG_SET_ORDER); foreach ($matches as $m) { var_dump($m); $key = $val = 0; foreach (str_split($m[1]) as $i => $c){ echo ord($c); $key += (ord($c) & 0x7f) << $i * 7; } foreach (str_split($m[2]) as $i => $c) { $val += (ord($c) & 0x7f) << $i * 7; } $ret[$key >> 3] = $val; } return $ret; } // Example of use: print_r(ved_decode('ahUKEwiHlMTro9_bAhVEtxQKHbTpDKAQFgiIAjAL'));
Output for 5.6.30, hhvm-3.18.5 - 3.22.0, 7.0.30 - 7.3.0alpha1
array(3) { [0]=> string(5) "�B��!" [1]=> string(2) "�B" [2]=> string(3) "��!" } 13366array(3) { [0]=> string(3) "�1:" [1]=> string(2) "�1" [2]=> string(1) ":" } 22949array(3) { [0]=> string(7) "��Q-" [1]=> string(6) "��Q" [2]=> string(1) "-" } 23224723019213381array(3) { [0]=> string(4) "��m" [1]=> string(2) "�" [2]=> string(2) "�m" } 1972array(3) { [0]=> string(2) ":C" [1]=> string(1) ":" [2]=> string(1) "C" } 58array(3) { [0]=> string(2) "(" [1]=> string(1) "(" [2]=> string(1) "" } 40array(3) { [0]=> string(3) "�"" [1]=> string(1) "" [2]=> string(2) "�"" } 5array(3) { [0]=> string(3) "�" [1]=> string(1) "" [2]=> string(2) "�" } 0Array ( [1056] => 549124 [796] => 58 [348077111165] => 45 [40] => 13959 [7] => 67 [5] => 4 [0] => 268 )