Advertisement
jargon

PHP Project Swap

Jun 12th, 2021
1,168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. function trk_fastregex( $pagedata = '' )
  4. {
  5.     $pattern = '/([\w\s.]*)({{(prj)\|([^|{}.]*)}})([\w\s.]*)/';
  6.     $replace = '{{$1}}<a href="./?({{$3}})={{$4}}">{{$4}}</a>{{$5}}';  
  7.     $subject = $pagedata;  
  8.     $matches = array();
  9.  
  10.     for( ; preg_match_all( $pattern, $pagedata, $matches ) ; )
  11.     {                  
  12.         foreach( $matches as $key => $value )
  13.         {
  14.             $subject =
  15.                
  16.                 str_replace(
  17.                
  18.                 '{{' . '$' . strval( $key + 1 ) . '}}',
  19.                
  20.                 $value,
  21.                
  22.                 $subject
  23.                
  24.                 );
  25.         }
  26.        
  27.         $matches = array();
  28.     }
  29.    
  30.     $pagedata = $subject;
  31.    
  32.     return $pagedata;
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement