Get the last character before a specific part of string in PHP
I would need a method to get the last character before a specific
substring in a string. I need this to check if it's a SPACE before the
specific substring, or not.
I am looking for a function like:
function last_character_before( $before_what , $in_string )
{
$p = strpos( $before_what , $in_string );
// $character_before = somehow get the character before
return $character_before;
}
if( $last_character_before( $keyword , $long_string ) )
{
// Do something
}
else
{
// Do something
}
No comments:
Post a Comment