regex - What does this PHP regular expression do? -


public function getblock( $tag )    {      preg_match ('#<!-- start '. $tag . ' -->(.+?)          <!-- end '. $tag . ' -->#si', $this->content, $tor);      $tor = str_replace ('<!-- start '. $tag . ' -->', "", $tor[0]);      $tor = str_replace ('<!-- end '  . $tag . ' -->', "", $tor);      return $tor; } 

does know function does?

public function getblock( $tag )    {      //below finds start tag, matches character multiple times      // until finds <!-- end $tag -->, store result in $tor      preg_match ('#<!-- start '. $tag . ' -->(.+?)          <!-- end '. $tag . ' -->#si', $this->content, $tor);       //the # delimiter, s meaning treat single line       // . matches \r\n example. , means insensitive       $tor = str_replace ('<!-- start '. $tag . ' -->', "", $tor[0]);      $tor = str_replace ('<!-- end '  . $tag . ' -->', "", $tor);       //remove line start on remove line end on.       return $tor;      //return between 2 lines. } 

ive added comments function, hope make more clear


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -