PHP如何在strpos之后添加变量字符串

问题描述 投票:-2回答:1

我正在获取网页的所有数据,然后在其中搜索某个字符串。我使用strpos查找位置,然后找到该位置,我想创建一个变量,该变量存储所有超过strpos 64个字符的信息。

例如:

$$ gin = strpos($ page,'content123')//然后在网页上找到位置后,在3个(共123个)之后添加另外64个字符。

为了澄清,我正在从网页获取文件内容,在页面数据中搜索位置(例如'内容),然后一旦找到该位置,我希望程序以64个字符捕获该标记之后的所有内容(这是一个变量)

编辑:

$begin = strpos($page, 'https://i2.au.reastatic.net/800x600/') + strlen('https://i2.au.reastatic.net/800x600/'); 
$end   = strpos($page, '/image.jpg');
$ImageName = substr($page, $begin, ($end - $begin));

$ImageContent = 'https://i2.au.reastatic.net/800x600/' . $ImageName . '/image.jpg';

PS,不确定为什么人们不赞成一个合法的问题?我以为这是一个互相帮助的地方。

谢谢

我正在获取网页的所有数据,然后在其中搜索某个字符串。我使用strpos查找位置,然后找到后,我想创建一个存储所有信息的变量64 ...

php string variables strpos
1个回答
0
投票

似乎您的代码是正确的

© www.soinside.com 2019 - 2024. All rights reserved.