\[\n\s+\],\n#', "=> [],\n", $dump); // Empties if (gettype($data) == 'object') { // Deal with object states $dump = str_replace('__set_state(array(', '__set_state([', $dump); $dump = preg_replace('#\)\)$#', "])", $dump); } else { $dump = preg_replace('#\)$#', "]", $dump); } if ($return===true) { return $dump; } else { echo $dump; } } switch ($input['mode']) { case 'serialize': $data = ''; // try any vaue try { eval("\$data = " . $input['data'] . ";"); echo serialize($data); } catch (Throwable $e) { try { eval("\$data = '" . addslashes($input['data']) . "';"); echo serialize($data); } catch (Throwable $e) { echo 'err: invalid syntax, use $val = [your text];'; } } break; default: $data = $input['data']; $result = unserialize($data); if ($result) { if (is_string($result)) { echo trim(var_export_short($result), "'"); } else { echo var_export_short($result); } } else { echo 'err: invalid syntax'; } break; }