文字图片分离

<?php
$str = 'aa<img src="http://www.test.com/upload/image/2014-03-24/7470ae223c752ed7677f90e72f6bffa8.jpg" />
        bbDDDDDD
        <img src="http://www.test.com/images/post/smile/default/e017.gif" />
        cc
        <img src="http://www.test.com/images/post/smile/default/e017.gif" />
        <img src="http://www.test.com/images/post/smile/default/e017.gif" />
        dd';

$res = preg_split('#(<img[^>]+>)#is', $str, -1, PREG_SPLIT_DELIM_CAPTURE);

echo '<pre>';
print_r($res);


你可能感兴趣的:(文字图片分离)