3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $values = array( 'a < b', 'a< b', 'a <b', 'a <b d> c' ); foreach ($values as $fieldValue) { var_dump(strip_tags($fieldValue)); $lastLessThanPos = strrpos($fieldValue, '<'); if (false === $lastLessThanPos) { continue; } $lastGreaterThanPos = strrpos($fieldValue, '>'); $nextChar = substr($fieldValue, $lastLessThanPos + 1, 1); var_dump($lastGreaterThanPos, $nextChar); }
Output for 4.3.2 - 7.2.0
string(5) "a < b" bool(false) string(1) " " string(4) "a< b" bool(false) string(1) " " string(2) "a " bool(false) string(1) "b" string(4) "a c" int(6) string(1) "b"
Output for 4.3.0 - 4.3.1
string(2) "a " bool(false) string(1) " " string(1) "a" bool(false) string(1) " " string(2) "a " bool(false) string(1) "b" string(4) "a c" int(6) string(1) "b"