Php 如何从indside a div获取指定内容

Php 如何从indside a div获取指定内容,php,jquery,phpquery,Php,Jquery,Phpquery,如何从#div内部获取内容(指定内容) 我的表格如下: <?php require_once('phpQuery/phpQuery.php'); $key-one = $_POST['key01']; $html = file_get_contents('http://google.com/search?q='.$key-one.''); phpQuery::newDocumentHTML($html); $result01 = pq('div#resultStats'); ?>

如何从#div内部获取内容(指定内容)

我的表格如下:

<?php
require_once('phpQuery/phpQuery.php');
$key-one = $_POST['key01'];
$html = file_get_contents('http://google.com/search?q='.$key-one.'');
phpQuery::newDocumentHTML($html);
$result01 = pq('div#resultStats');
?>

<body>
<form name="form1" method="post" action="1.php">
    <input type="text" name="key01"><br>
    <input type="submit" name="Submit" value="Submit">
</form>
</body>
但我只想

1,570,000,000

提前感谢。

您可以使用PHP
str\u replace

假设
$result01
显示
约15700000个结果

$result01 = str_replace("About ","",$result01);
$result01 = str_replace(" results","",$result01);

在这些更改之后,
echo$result01
将显示
15700000

您也可以使用preg\u replace,如

 $result = preg_replace('/[^\sa-z]/i', '', $string);

这将删除字符串中的所有字符和空格

它起作用了,谢谢!:)顺便说一句,在提交文本表单时,我指的是两个分开的单词,比如“一两”-我有没有可能提交“一+二”这样的“空格”?我不太清楚你的意思。如果您只是用另一个字符串替换一个字符串,那么应该没有问题。例如,我以“text1 text2”的形式键入,但我想将这两个单词之间的“空格”替换为“加号”,如“text1+text2”,是的,那么您只需执行
stru replace(“,“+”,$string)希望这有帮助:)法律,待定。我按照你之前给我看的方式做了,而且效果很好,
$01=str_replace(“,“+”,$01)非常感谢!你的老板。
 $result = preg_replace('/[^\sa-z]/i', '', $string);