Advertisement
Guest User

Untitled

a guest
Apr 20th, 2012
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.56 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @author Chris Horeweg in response to http://stackoverflow.com/questions/10248031/php-read-content-and-do-a-preg-match
  5.  */
  6.  
  7. $content = "@font-face {
  8.  font-family: 'someFonts';
  9. }
  10.  
  11. @font-face {
  12.  font-family: 'someotherFonts';    
  13. }
  14.  
  15. .style {
  16.  font-family: 'someFonts';
  17. }";
  18. if (!preg_match('#@font-face {([^;]+);#i', $content, $matches)) {
  19.   echo 'Not Found';
  20. }
  21. else {
  22.     echo print_r($matches, true);
  23. }
  24. /** Output:
  25.  
  26. Array
  27. (
  28.     [0] => @font-face {
  29.   font-family: 'someFonts';
  30.     [1] =>
  31.   font-family: 'someFonts'
  32. )
  33.  
  34. **/
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement