I am trying to replace new lines of a code with html ol tag to display the code as
1. Line 1
2. Line 2
3. Line 3
4. Line 4
Here is my php
$x="Line 1
Line 2
Line 3
Line 4";
echo preg_replace("/
+([^
]+)/","<ol start='1'><li>$1</li></ol>",$x);
The problem is ol tag is not looping in the preg_replace() function,so It outputs
1. Line 1
1. Line 2
1. Line 3
1. Line 4
What is wrong with the code?