Advertisement
jargon

PHP Project Swap

Jun 12th, 2021
1,375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 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. ?>
  36.  
  37. Error Line:
  38.                 $subject
  39.  
  40. Error Message:
  41. Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in C:\xampp8\htdocs\puzzlum.net\php\trk swaps.php:22 Stack trace: #0 C:\xampp8\htdocs\puzzlum.net\php\trk swaps.php(22): str_replace('{{$1}}', Array, '<style>{{font.m...') #1 C:\xampp8\htdocs\puzzlum.net\index.php(129): trk_fastregex('<style>{{font.m...') #2 {main} thrown in C:\xampp8\htdocs\puzzlum.net\php\trk swaps.php on line 22
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement