我正在一个提供站点指标的站点上,它使用gtmetrix的API。所以我想从即将到来的结果中删除特定的数据,但我只是不知道该怎么做。一些帮助,将不胜感激!
<?php
require_once('service.inc.php');
$test = new Services_WTF_Test("email", "api_key");
$url_to_test = "https://google.me/";
echo "Testing $url_to_test\n";
$testid = $test->test(array(
'url' => $url_to_test
));
if ($testid) {
echo "Test started with $testid\n";
}
else {
die("Test failed: " . $test->error() . "\n");
}
echo "Waiting for test to finish\n";
$test->get_results();
if ($test->error()) {
die($test->error());
}
$testid = $test->get_test_id();
echo "Test completed succesfully with ID $testid\n'<br>";
$results = $test->results();
if ($results): ?>
<?php
foreach($results as $result => $data): ?>
<strong><?php $ukey = strtoupper($result);
echo $ukey; ?>:</strong>
<?php echo $data; ?><br><br>
<?php endforeach;
endif;
?>
输出为: FIRST_CONTENTFUL_PAINT_TIME:1495
PAGE_ELEMENTS:44
REPORT_URL:https://gtmetrix.com/reports/google.me/BFylJNX3
REDIRECT_DURATION:0
FIRST_PAINT_TIME:1495
DOM_CONTENT_LOADED_DURATION:
DOM_CONTENT_LOADED_TIME:1908
我想从api REPORT_URL中删除第3个数据:
答案 0 :(得分:0)
您可以在foreach中跳过REPORT_URL
$ukey = strtoupper( $result );
if( $ukey != 'REPORT_URL' ) {
echo '<strong>' . $ukey . '</strong>';
echo $data . '<br><br>';
}