0

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?

2
  • Just 'txnid' => $b, no need to echo. Commented Feb 18, 2015 at 12:51
  • That was the mistake, thanks :) Commented Feb 18, 2015 at 12:52

3 Answers 3

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

This should work.

Sign up to request clarification or add additional context in comments.

1 Comment

@panther Thanks for pointing out, I have corrected the error.
1

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.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.