Swee Hong
Swee Hong

Reputation: 539

PHP assign a $string in to array

I have an action like this:

updatecreditbyaction('updatecredit', $_GET['uid'], array('extcredits2' => '+'.$paycredit));

The updatecredit is action name.

The $_GET['uid'] is a user UID number.

The array('extcredits2' => '+'.$paycredit) is add the $paycredit amount to extcredits2.

My question is, I would like to use $extown to replace the extcredits2

I try the below coding,

$extown = "extcredits99";
updatecreditbyaction('updatecredit', $_GET['uid'], array($extown => '+'.$paycredit));

but when $extown inside the action, it was a blank value, not extcredits99 how to resolve it?

Thank you.

Upvotes: 0

Views: 47

Answers (1)

Firas Rassas
Firas Rassas

Reputation: 509

Try this:

$extown = array();
$extown['extcredits99'] = '+'.$paycredit;
updatecreditbyaction('updatecredit', $_GET['uid'], $extown);

Upvotes: 1

Related Questions