3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stripNonValidCharaters ($message) { $message = mb_convert_encoding($message, 'UTF-16', 'UTF-8'); $count = 0; //mostly taken from https://dynmark.uservoice.com/knowledgebase/articles/83496-gsm-alphabet-character-set $search = [ '`', '‘', '’', //single quotes '“', '”', //double quotes '~', '¬', '|', //misc chr(0xc2a0) //nbsp character ]; $replace = [ "'", "'", "'", //single quotes '"', '"', //double quotes '-', '-', 'I', //misc " " //space ]; $message = str_replace($search, $replace, $message, $count); $message = trim($message); return ['message' => $message, 'replacements' => $count]; } $message = "We can’t wait to see you at our Open Day next week. We’ve sent you an email with all the info you need. If you’ve not received it please call 01252 892883"; var_dump(stripNonValidCharaters($message));
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["message"]=> string(307) "We can t wait to see you at our Open Day next week. We ve sent you an email with all the info you need. If you ve not received it please call 01252 892883" ["replacements"]=> int(0) }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
63.31 ms | 402 KiB | 8 Q