3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $passes = ["fo\"obar", "foobar\"", "foobar\\\\\"", "foo\\\"\"bar"]; $expect = '{"foo":{"password":"****"}}'; foreach ($passes as $pass) { $json = json_encode(["foo"=>["password"=>$pass]]); if ($expect !== preg_replace('{("password"\s*:\s*)"(?:[^"\\\\]|(?:\\\\.))*"}', '$1"****"', $json)) { echo "Password $pass is out of this league!"; exit(1); } } echo "Filter test ok!";
based on SF8Br
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
Filter test ok!