Jump to content

Only print text from $variable before defined text string.


Silvar

Recommended Posts

$pos = strpos($description, 'I hate this part');

if ($pos !== false) {
    $firstpart = substr($description, 0, $pos);
}else {
    echo 'Section was not found';
}

echo $firstpart;

 

Using a mixture of substr and strpos

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.