Get everything after word

Hmm you don't want to use some simple things like :

$str = substr($lorem, strpos($lorem, 'Nulla'));

if you do not want to look for Nulla, but also for 'null' you might consider using stripos instead of strpos... This code will include Nulla in the returned value. If you want to exclude Nulla, you might want to add it's lentgh to the strpos value i.e

$str = substr($lorem, strpos($lorem, 'Nulla') + 5);

At last, if you need to have something a bit more generic, and as suggested @Francis :

$needle = 'Nulla'; 
$str = substr($lorem, strpos($lorem, $needle) + strlen($needle));

Honestly regexp are overkill for something like this...


Try this:

$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla felis diam, mattis id elementum eget, ullamcorper et purus.";
$prefix = "Nulla";
$index = strpos($string, $prefix) + strlen($prefix);
$result = substr($string, $index);

Tags:

Php

Regex