14.02.2017, 13:49
IsSequence
Gist Link
This function checks given string is a sequence of another string.That means a string can be extracted from another string by removing the words in order.For example string "samp" is a sequence of string "san andreas multiplayer".This function uses standard recursion for traversing.
ParametersGist Link
This function checks given string is a sequence of another string.That means a string can be extracted from another string by removing the words in order.For example string "samp" is a sequence of string "san andreas multiplayer".This function uses standard recursion for traversing.
- main_string - string need to be checked in
- sub_string - sub string which is sequence of main_string
- first_size - size of main string (optional)
- second_size - size of sub string (optional)
PHP код:
bool:IsSequence( main_string[ ] , sub_string[ ] , first_size = sizeof( main_string ) , second_size = sizeof( sub_string ) )// by Sreyas
{
if( !second_size ) return true;
if( !first_size ) return false;
if( main_string[ first_size - 1 ] == sub_string[ second_size - 1 ] )
return IsSequence( main_string , sub_string , first_size - 1 , second_size - 1 );
return IsSequence( main_string , sub_string , first_size - 1 , second_size );
}