为了方便进一步的工作,我将一个数组转移$row到另一个数组并按 id 拆分它,如下所示:$services
$services = [];
while($row = $results->fetch_assoc()) {
if ($row["payment_service"] == 'PayPal'){
$paypal_item_number = $row["id"];
$paypal_amount = $row["amount"];
$paypal_curr_code = $row["currency_code"];
$services[$row["id"]] = $row;
}
}
例如,第一个数组有需要更改的数据,["paypal_email"]=> string(16) "book@ya.ru"但我需要得到结果["business"]=> string(16) "book@ya.ru"。那些。我需要更改一些默认取自数据库的名称,并且无法在其中提前更改。
如何在创建第二个数组时更改名称?
大批
array(8) {
["id"]=>
string(2) "74"
["amount"]=>
string(2) "10"
["currency_code"]=>
string(3) "USD"
["validity"]=>
string(2) "72"
["payment_service"]=>
string(6) "PayPal"
["paypal_email"]=>
string(16) "book@ya.ru"
["stripe_pkey"]=>
string(0) ""
["status"]=>
string(1) "1"
}...
你也可以使用
array_map然而