3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $data = 'Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down Interface IP Address S/L Description --------- ---------- --- ----------- eth0 192.168.1.1/24 u/u Local eth0.51 192.168.5.1/24 u/u Dev 1 eth1 x.x.x.x/24 u/u Internet eth2 192.168.2.1/24 u/D Local 2 lo 127.0.0.1/8 u/u ::1/128 tun35 192.168.4.222/24 u/u'; $string = 'eth'; $datastart = strpos($data,$string); $datastart = $datastart -1; $pattern ='lo 127.0.0.1/8 u/u ::1/128'; $replace = ''; echo "$pattern"; echo '<br />'; $data = substr($data,$datastart); $data = str_replace($pattern,$replace, $data); echo "$data";
Output for 5.3.22 - 7.2.0
lo 127.0.0.1/8 u/u ::1/128<br /> eth0 192.168.1.1/24 u/u Local eth0.51 192.168.5.1/24 u/u Dev 1 eth1 x.x.x.x/24 u/u Internet eth2 192.168.2.1/24 u/D Local 2 tun35 192.168.4.222/24 u/u