How to read string from a specific word?

Asked

Viewed 684 times

0

my doubt is as follows:

If I have the phrase "The rat gnawed on the clothes of the king of rome"

How do I read only from "Roeu" to "roma"?

This without using numbers, because there will be several sentences of different sizes.

I searched in the php documentation the strings functions found several but could not do exactly this.

For an even more practical example, what I actually have is a list of links but they’re like

/79811/out.php=www.youtube.com=? video1 /798354664561/out.php=www.youtube.com=? video1

These strings have different widths and I want to pick from www until the end of the string

2 answers

1


How about this?

$a = '79811/out.php=www.youtube.com=?video1';
$b = 'www';
echo substr( $a, strpos($a, $b);
  • Would it work if it were just a sentence in the reality I have a long list of sentences.

  • You asked how to read a string from a position. The rest of the logic: put the string in the $variable from any object and assign the results to another object would be with you.

0

display from "3" to "8"

$frase = "123456789";


$primeira = strripos("$frase", '3');
$utima    = strripos("$frase", '8');

    $retirar = $utima - $primeira ;
    $exibir = substr($frase, $primeira, $retirar);

    echo "$exibir" ;


 exibir : 34567

Browser other questions tagged

You are not signed in. Login or sign up in order to post.