6

求教个 PHP 的 substr 问题 ....

 1 year ago
source link: https://www.v2ex.com/t/884964
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  PHP

求教个 PHP 的 substr 问题 ....

  imSam · 2 小时 20 分钟前 · 390 次点击
知道要被程序员大佬们笑掉大牙了,但实在是搞不懂了,
正在做一个网站,希望能通过 PHP 调用 steam 上某款游戏的实时在线人数,所以在网上找了一段代码:

<?php
$str=file_get_contents('https://steamcommunity.com/app/200210');
if ($x=strpos($str,'<span class="apphub_NumInApp">')) $str=substr($str,$x);
if ($x=strpos($str,'</span>')) $str=substr($str,0,$x);
echo $str;
?>

这样倒是可以调取我要的内容了,但是输出的是

<span class=”apphub_NumInApp“>1,910 In-Game

怎么改才能不要前边的 [ <span class=”apphub_NumInApp“> ] 呢?谢谢

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK