重复3个数字中最后一个的变量


variable echoing out the last of 3 numbers

嗨,所以我目前收到了一个来自web抓取脚本的176 8 58的输出。我想把这个脚本打包成一个变量,并在网站上的其他地方进行呼应。

我已经通过做把它打包了

ob_start();
echo $node->nodeValue. "'n";
$thenumbers = ob_get_contents();
ob_end_clean();

但当我像这个一样回显时

现在,在网站上,数字以跨度为单位,并用"/"分隔。我需要做一些花哨的事情吗?我是PHP的新手,所以让我知道它是否愚蠢!

<?php echo $thenumbers ?>

我的输出是176 8 58

非常感谢的帮助

(我使用的网页抓取脚本不得不隐藏我正在抓取的网站,因为它正在开发中)

<?php
$teamlink = rwmb_meta( 'WEBSITE_HIDDEN' );
$arr = array( $teamlink ); 
foreach ($arr as &$value) {
    $file = $DOCUMENT_ROOT. $value;
    $doc = new DOMDocument();
    $doc->loadHTMLFile($file);
    $xpath = new DOMXpath($doc);
    $elements = $xpath->query("//*[contains(@class, 'table')]/tr[3]/td[3]/span");
    if (!is_null($elements)) {
        foreach ($elements as $element) {
            $nodes = $element->childNodes;
            foreach ($nodes as $node) {
                ob_start();
                echo $node->nodeValue. "'n";
                $win_loss = ob_get_contents();
                ob_end_clean();
            }
        }
    }
}
?>

p.s我知道这个脚本目前输出的标准文本很好。

如果我完全误解了你的问题,我会感到抱歉。

如果你想在数字之间加一个"/",空格在哪里,你可以:

 echo str_replace(' ','/',$thenumbers);

如果你只想显示最后3位数字(清除字符串中的空格),你可以;

 echo substr(str_replace(' ','',$thenumbers),-3);