If the value of a variable (i.e. $var="^hello
";) starts with a given character (i.e. ^
), how could I return the remainder of that variable (i.e. hello
), and returnFALSE
(or NULL
or 0
if easier) if it doesn't start with the given character? Note that there is no guarantee that the variable will be a string. I tried the following, but it results in errors if the value is NULL.
$var='^hello'; //Works
$var=123; //Works
$var=NULL; //Doesn't work
echo ($var[0]=='^')?substr($var,1):false;
echo($new);