Location: PHPKode > scripts > Propagator > propagator/strtools.php
<?php

class StrTools
{
   function count($base,$sea)
   {
      $ctr=0;
      $i=0;
      while(true)
      {
         do
         {
            $i=strpos($base,$sea,$i);
            if($i===false)
            {
               break 2;
            }
            $i+=1;
            $ctr+=1;
         } while(false);
      }
      return $ctr;
   }

   
   function split($line,$delims=" \t\r\n")
   {
      $words=array();
      $newword="";
      $_L3=strlen($line);
      for($__3 = 0; $__3 < $_L3; $__3++)
      {
         $c=$line{$__3};
         if(strstr($delims,$c))
         {
            if($newword!="")
            {
               array_push($words,$newword);
               $newword="";
            }
         }
         else
         {
            $newword.=$c;
         }
      }
      if($newword!="")
      {
         array_push($words,$newword);
      }
      return $words;
   }

   function splitAll($str,$delimiters=" \r\n\t")
   {
      $words=array();
      $newword="";
      $delimseq="";
      $_L3=strlen($str);
      for($__3 = 0; $__3 < $_L3; $__3++)
      {
         $c=$str{$__3};
         if(strstr($delimiters,$c))
         {
            if($newword!="")
            {
               array_push($words,$newword);
               $newword="";
            }
            $delimseq.=$c;
         }
         else
         {
            if($delimseq!="")
            {
               array_push($words,$delimseq);
               $delimseq="";
            }
            $newword.=$c;
         }
      }
      if($newword!="")
      {
         array_push($words,$newword);
      }
      if($delimseq!="")
      {
         array_push($words,$delimseq);
      }
      return $words;
   }

   function join($wordlist)
   {
      $str="";
      reset($wordlist);
      do
      {
         $w= current($wordlist);
         $str.=$w;
      }
      while(!(next($wordlist) === false));
      return $str;
   }

}
$_StrTools_cdelimiters=" \\.()[]{},;:?+-*=/&~|\"\'<>!\r\n\t";
?>
Return current item: Propagator