|
|
|
Wednesday, 23 November 2011 06:14 |
// Finding mulitple occurences of a string withing another
Cheap Ativan no rx. Buy free overnight pharmacy Ativan. How to purchase Ativan onlin Valium delivery to US Montana. Buying Valium overnight. Buy Valium no visa online.
function multipleSubstringOccurences($string,$substring)
{
$string=strtolower($string);
$substring=strtolower($substring);
$matched_positions=array();
$sample_string_to_be_matched=$string;
$string_to_be_found=$substring;
$strlen_string_to_be_found=strlen($string_to_be_found);
$matched_positions[]=strpos($sample_string_to_be_matched,$string_to_be_found);
if(strpos($sample_string_to_be_matched,$string_to_be_found))
{
$current_array_index=0;
$cur_pos=strpos($sample_string_to_be_matched,$string_to_be_found)+$strlen_string_to_be_found;
$still_finding=true;
while($still_finding)
{
$sample_string_to_be_matched=substr($sample_string_to_be_matched,$cur_pos,strlen($sample_string_to_be_matched));
if(strpos($sample_string_to_be_matched,$string_to_be_found))
{
$still_finding=true;
$cur_pos=strpos($sample_string_to_be_matched,$string_to_be_found)+$strlen_string_to_be_found;
$matched_positions[]=$matched_positions[$current_array_index]+strpos($sample_string_to_be_matched,$string_to_be_found)+$strlen_string_to_be_found;
$current_array_index++;
}
else
{
$still_finding=false;
}
}
}
else
{
return false;
}
return $matched_positions;
}
//Usage
$string_main="Life is sometimes hard. Sometimes it's delightful.";
$string_to_find="Sometimes";
$res_array=array();
$res_array=multipleSubstringOccurences($string_main,$string_to_find);
/*
Will return an array with all starting indexes of string "sometimes".
*/
Buy Phentermine on line without a prescription. Phentermine non prescription. Who ca Cheap Amoxicillin c.o.d.. Amoxicillin cash on delivery overnight. Amoxicillin from i Read more: |
|
|
|
|
|
|
|
|