3v4l.org

run code in 150+ 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); var_dump($lastGreaterThanPos, $nextChar); }
Output for 4.3.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
string(5) "a < b" bool(false) string(1) "<" string(4) "a< b" bool(false) string(1) "<" string(2) "a " bool(false) string(1) "<" string(4) "a c" int(6) string(1) "<"
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) "<" string(4) "a c" int(6) string(1) "<"