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?

有帮助吗?

解决方案

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

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top