Article Cruise

Latest news, Technologies, TV series, Movies, Design and Fashion, DIY

PHP Get All Strings between Start and end

Posted on | May 3, 2015 | No Comments

There are lots of resources on the web, but I could not get any to work properly. So, I’ve written my own as simply as possible:

function get_all_strings_between($string, $start, $end){
   $res=array();
   $tmp=explode($start,$string);
   $c=count($tmp);
   for($i=1;$i<$c;$i++){
      $v=$tmp[$i];
      if(strrpos($v,$end)!==false){
         $tmp1=explode($end,$v);
         if(count($tmp1)>1){
            $res[]=$tmp1[0];
         }
      }
   }
   return $res;
}

Comments

Search

Admin message

The articles posted in French are different than the ones in English!

Social

Archives

About

We post what we think, we post news, we post...

Subscribe to our feed

Admin