How can I test if string start with "<" and end with ">" and print true if that true.
$Text="<hi how are you>"; // true
$Text=" any <hi how are you>"; // false
$Text="<hi how are you> any"; // false
Maybe this works: (didn't test)
if(ereg("(^<).*(>$)", $Text)) { echo "true" } else { echo "false"; }
try the above regex solution or the this simple code below:
if($text[0]=='<'&&$text[strlen($text)-1]=='>') echo "true"; else echo "false";