eval.in

Paste #3556

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] => <img
    [2] =>  alt="amj" src="https://domain.com/images7.jpg" /> 
    [3] => <img
    [4] =>  alt="Ea" src="http://domain.com/images3.jpg" /> 
    [5] => <img
    [6] =>  alt="amj" src="https://domain.com/images7.jpg" /> 
    [7] => <img
    [8] =>  alt="amj" src="https://domain.com/images7.jpg" />
)

OK (0.008 sec real, 0.008 sec wall, 13 MB, 127 syscalls)

Fork