Pergunta

I want to be able to only store the 11 characters following a certain keyword (watch?v=) in PHP, nothing after and nothing before. How do I achieve this?

Foi útil?

Solução

Use strpos() to find the watch?v=, then use the substr() method to get 11 characters after.

docs for the strpos function: http://us2.php.net/strpos

docs for the substr function: http://www.php.net/manual/en/function.substr.php

Outras dicas

You can do it with PHP strpos() and substr() functions.

echo substr($string, strpos($string, "keyword"), length);

In here,
$string - url,
"keyword" - watch?v=,
$length - 11

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top