Kezman10
Kezman10

Reputation: 3

PHP Delete an entire string from the beginning of a word

I need to delete all the string type content that is from the beginning of a word, I give you an example

Lorem Ipsum is simply the dummy text of printers and text files. Lorem Ipsum has been the industry's standard dummy text since the 1500s, when an unknown printer used a gallery of type and mixed it up in such a way that he managed to make a specimen textbook. Not only did it survive 500 years, but it also entered as a text of

I have to delete from unknown, including unknown, and the result should be the following

Lorem Ipsum is simply the dummy text of printers and text files. Lorem Ipsum has been the industry's standard dummy text since the 1500s, when an

thanks for al

Upvotes: 0

Views: 36

Answers (1)

מתניה אופן
מתניה אופן

Reputation: 148

$stc_txt = "Lorem Ipsum is simply the dummy text...";
$cut_by = "unknown";
$pos = strpos($stc_txt, $cut_by);
$result = substr($stc_txt, 0, $pos);
print($result);

If you don't want the 1st ocurance of $cut_by you can change the parameters for strpos, or specify the index in another way. More data is needed to help with this.

Upvotes: 1

Related Questions