如何在Laravel中使用数组内部变量?

时间:2018-07-01 10:16:11

标签: php laravel

我要获取用户输入的自定义金额以在Web上付款,我正在使用Payeer com api 我如何获得数组内的自定义金额。

可变自定义金额

$ trans->美元

我尝试关注但未遵循工作代码

<?php
$m_shop = '547754002';
$m_orderid = '1';
$m_amount = $trans->usd;
$m_curr = 'USD';
$m_desc = base64_encode('Test');
$m_key = 'Your secret key';

$arHash = array(
    $m_shop,
    $m_orderid,
    $m_amount,
    $m_curr,
    $m_desc
);

1 个答案:

答案 0 :(得分:-1)

您可以使用array_push功能。您的代码将是

<?php
$m_shop = '547754002';
$m_orderid = '1';
$m_amount = $trans->usd;
$m_curr = 'USD';
$m_desc = base64_encode('Test');
$m_key = 'Your secret key';

$arHash = array();
array_push(
    $arHash,
    $m_shop,
    $m_orderid,
    $m_amount,
    $m_curr,
    $m_desc
)