在数组中分配PHP变量

I'm working on integrating external code. Following is the code:

if(count($_POST))
pay_page(array('key'=>'gtKFFx','txnid'=>'shanil','amount'=>'100');

There are static values. I want to assign php variables to this array:

if(count($_POST))
pay_page(array('key'=>'gtKFFx','txnid'=><?php echo $b; ?>,'amount'=>'10');

How do I achieve that? Can somebody help?

if(count($_POST))
    pay_page(array('key'=>'gtKFFx','txnid'=> $b,'amount'=>'10'));

This should work.

Just write there $b, no <?php etc. You are in PHP script, so there is no reason why to begin PHP script again.

if(count($_POST))
    pay_page(array('key' => 'gtKFFx', 'txnid' => $b, 'amount' => 10));

Note:
- There was missing bracket at the end of the script
- amount is number, so it should be written without quotes.

If you are in out of php script i.e your code is correct.

Now you are in php script only. so echo is not required.

so just use like below code:

if(count($_POST))
    pay_page(array('key' => 'gtKFFx', 'txnid' => $b, 'amount' => 10));

I think this is useful.