PHP如何将数组的第一个值设置为字符串变量

PHP如何将数组的第一个值设置为字符串变量,php,arrays,string,variables,Php,Arrays,String,Variables,我试图获取数组的第一个值,并将其设置为可以用作int的变量 我尝试过内爆,但我认为这不是正确的函数 $username = gotten from user input $password = gotten from user input $detail = Customer::getCustomerDetails(array(':username' => $username, ':password' => $password)); $customerProfile = Custom

我试图获取数组的第一个值,并将其设置为可以用作int的变量

我尝试过内爆,但我认为这不是正确的函数

$username = gotten from user input
$password = gotten from user input
$detail = Customer::getCustomerDetails(array(':username' => $username, ':password' => $password));
$customerProfile = Customer::getCustomerProfile(array(':detail' => $detail));
Customer::getCutomerDetails是一个从数据库查询返回客户编号的函数。查询工作100% 我想保存$detail数组输出的第一个值,并在getCustomerProfile函数中使用它来获取客户的配置文件


我收到一个“数组到字符串转换”错误。我知道这是因为$detail是一个数组,getCustomerProfile函数需要一个字符串。请帮助使用类型转换

代码可能是这样的

 $customerProfile = Customer::getCustomerProfile(array(':detail' => (int)$detail['username']));


$detail[0]或$detail['username']仍然不起作用,伙计?像这样不,试过了。它仍然以数组形式显示
Customer::getCustomerDetails()
返回、显示
var\u dump($detail)的内容它返回“74”我需要在Customer::getCustomerProfile()中使用该74抱歉,您希望它以整数类型返回吗?方法不正确,如何知道第一个数组元素的当前键是什么?这给了我以下错误:PDOStatement::execute()希望参数1为数组,int为给定值。当我从Customer::getCustomerProfile(数组(':detail'=>$detail))中删除$detail时;硬代码“74”代替$detail,它工作得很好。必须是$detail[0]或$detail['username']我已经尝试过了,它仍然会给我数组到字符串的转换错误try var_dump($detail)。我想知道
$customerProfile = Customer::getCustomerProfile(array(':detail' => (int)$detail[1]));