eval.in

Paste #3555

PHP — PHP 5.4.6, pasted 1 year ago

1
2
3
4
5
6
7
<?php

$string = '<p>First sentence here comes.&nbsp; Second sentence here it is.&nbsp; One more sentence.&nbsp;&nbsp;</p> <img alt="amj" src="https://domain.com/images7.jpg" /> <img alt="Ea" src="http://domain.com/images3.jpg" /> <img alt="amj" src="https://domain.com/images7.jpg" /> <img alt="amj" src="https://domain.com/images7.jpg" />';

$result = preg_split('/<img/', $string, null, PREG_SPLIT_DELIM_CAPTURE);

print_r($result);

Program Output

Array
(
    [0] => <p>First sentence here comes.&nbsp; Second sentence here it is.&nbsp; One more sentence.&nbsp;&nbsp;</p> 
    [1] =>  alt="amj" src="https://domain.com/images7.jpg" /> 
    [2] =>  alt="Ea" src="http://domain.com/images3.jpg" /> 
    [3] =>  alt="amj" src="https://domain.com/images7.jpg" /> 
    [4] =>  alt="amj" src="https://domain.com/images7.jpg" />
)

OK (0.004 sec real, 0.005 sec wall, 13 MB, 91 syscalls)

Fork