在数组键值对中使用变量作为值

I am using Braintree to do some payment processing and I am sending data from my swift app and I instead of hardcoding the amount, I want it to be dynamic based on which product I select. Is it possible to set the value of a key value pair to be a dynamic variable that is coming into my PHP script?

<?php

$price =  htmlentities($_REQUEST["price"]);

$tr_data = Braintree_TransparentRedirect::transactionData(
                array('redirectUrl' => "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH),
                'transaction' => array('amount' => $price, 'type' => 'sale')))
?>
查看全部
dongleiqiao4906
dongleiqiao4906
2016/11/10 17:19
  • php
  • key-value
  • arrays
  • 点赞
  • 收藏
  • 回答
    私信

0个回复