Advertisement
Guest User

RegexSimple

a guest
Feb 18th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1.        include_once 'lib/Simple_html_dom.php';
  2.        
  3.        
  4.         $string = '
  5.            <p>Aliquam vehicula faucibus tellus. Praesent condimentum commodo libero,
  6.            sit amet pellentesque metus bibendum sit amet. Donec commodo tortor in
  7.            libero consequat suscipit. Maecenas eget augue vulputate neque pulvinar lobortis.
  8.            Fusce posuere lorem scelerisque, facilisis velit eu, vehicula nulla. Mauris
  9.            vestibulum vulputate justo, et tincidunt neque imperdiet eget.</p>
  10.            <img alt="" src="/upload/ckeditor/CARTOAEROMED2.jpg" style="width: 800px; height: 648px;" />
  11.            <img alt="" src="/upload/ckeditor/CARTOAEROMED2.jpg" style="width: 800px; height: 648px;" />
  12.            <img alt="" src="/upload/ckeditor/CARTOAEROMED2.jpg" style="width: 800px; height: 648px;" />';
  13.        
  14.          $html = new Simple_html_dom($string);
  15.          $result = new stdClass;
  16.          foreach($html->find('img') as $img)
  17.          {
  18.              $src = '"" src="/common/function/thumb.php?url=../..' . $img->src . '" class="img-responsive img-rounded" ';      
  19.              $result = preg_replace('/src([=]|\s=)"(.*)"/', $src, $string);
  20.          }      
  21.                
  22.          print_r($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement