SHARE
TWEET

Untitled

phpist Oct 21st, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Как </strong> появился в строке?
  2.  
  3. Листинг 20.16. Функция preg_replace_callback_array(). Файл replace_callback_array.php
  4. <?php ## Функция preg_replace_callback_array()
  5. $str = '<hTmL><bOdY>Hello world!</bOdY></html>';
  6. $str = preg_replace_callback_array(
  7. [
  8. '{(?<btag></?)(?<content>\w+)(?<etag>.*?>)}s' => function($m) {
  9. return $m['btag'].strtoupper($m['content']).$m['etag'];
  10. },
  11. '{(?<=>)([^<>]+?)(?=<)}s' => function($m){ return "<strong>$m[1]</strong>"; }
  12. ],
  13. $str);
  14. echo htmlspecialchars($str);
  15. ?>
  16. Результатом выполнения скрипта будет следующая строчка:
  17. <HTML><BODY><strong>Hello world!</strong></BODY></HTML>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top