Advertisement
jargon

This is the correction to mk11STATSRAW

Oct 11th, 2021
1,551
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. <?php
  2.  
  3. $page = <<< TXT
  4. CASE "grml"\r\n
  5.    prflidty$ = "Gremlin"\r\n
  6.    prflactn$ = "movebitepnch"\r\n
  7.    IF RND(1) > .2 THEN\r\n
  8.     prflactn$ = prflactn$ + "dggr"\r\n
  9.    END IF\r\n
  10.    prflgpic$ = "grml"\r\n
  11.    prflidty! = 4\r\n
  12.    prflhp! = 25\r\n
  13.    prflstr! = 90\r\n
  14.    prflspd! = 1\r\n
  15.    prflarmr! = 1\r\n
  16.    prflvalu! = 5\r\n
  17.    prflpirc! = 2\r\n
  18.    prfllv! = 1\r\n
  19.    prflhpmax! = 25\r\n
  20.    prflstrmax! = 90\r\n
  21. TXT;
  22.  
  23. echo '<html><head><title>mk11STATSRAW</title></head><body>'.gen_statsheet($page).'</body></html>';
  24.  
  25. function gen_statsheet( $page = '' ) {
  26.     $return = '';
  27.  
  28.     $pattern =    '/(?:prfl(?<stat>idty|hp|str|spd|armr|valu|pirc|lv|hpmax|strmax|essmax|essspd)!) = (?<value>[.\d]+)/';
  29.    
  30.     while( preg_match( $pattern, $page, $matches, PREG_UNMATCHED_AS_NULL ) )
  31.     {
  32.         if( isset( $matches[ 'stat' ] ) and isset( $matches[ 'value' ] ) )
  33.         {
  34.             if( !is_null( $matches[ 'stat' ] ) and !is_null( $matches[ 'value' ] ) )
  35.             {
  36.                 $return .= '<p>'. $matches[ 'stat' ]. '='. $matches[ 'value' ]. '</p>';
  37.                 $page = str_replace( $matches[0], '', $page );
  38.             }
  39.         }
  40.     }
  41.     return $return;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement