显示返回列表中的单个结果

Display Single Result from Returned List

我正在尝试找出如何只显示第一个返回值(phone 数字)。目前此代码 returns 所有可用号码,但我只想向客户显示一个。

这是代码。我希望有人能帮帮忙。我对此很陌生,你看,我已经尝试了一些但没有奏效。

<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC1f3ccf29618exxxxx"; 
$token = "{{Auth_Token}}"; 
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList('GB', 'Local', array(
        "Contains" => "44161"
    ));

foreach($numbers->available_phone_numbers as $number) { 
echo $number->phone_number;
}

?>

目前我得到的列表如下:

+441618503707+441618503748+441618502214+441618502601+441618502327+441618503631+441618503785+441618503437+441618503432+441618503758+441618503593+441618503404+441618503794+441618502289+441618503684+441618503519+441618503629+441618503810+441618503704+441618503742+441618503557+441618503302+441618503604+441618503539+441618503044+441618503298+441618503799+441618503753+441618503447+441618503801

我只想显示第一个值 IE +441618503707

感谢帮助,我可能不会立即回复,因为这是目前正在进行的众多项目之一。请放心,尽管我的其他项目都在 Infusionsoft 上,但我不会经常涉足 API/PHP!

然后你可以使用这个

echo $numbers->available_phone_numbers[0]->phone_number;

它将包含数组中的第一个。

更新

<?php
// Get the PHP helper library from twilio.com/docs/php/install
require_once('Services/Twilio.php'); // Loads the library

// Your Account Sid and Auth Token from twilio.com/user/account
$sid = "AC1f3ccf29618exxxxx"; 
$token = "{{Auth_Token}}"; 
$client = new Services_Twilio($sid, $token);

$numbers = $client->account->available_phone_numbers->getList('GB', 'Local', array(
        "Contains" => "44161"
    ));

echo $numbers->available_phone_numbers[0]->phone_number;

?>