I want to add variables into a string in php. I googled and found the method of : "{$a}". However this doesn't work for me. I echoed it and it has literally echoed "{$a}" instead of the actual value of the variable. Here is my code:
$body= json_decode(
'{
"sender_batch_header":
{
"email_subject": "SDK payouts test txn"
},
"items": [
{
"recipient_type": "EMAIL",
"receiver": "{$email}",
"note": "Your 1$ payout",
"sender_item_id": "Test_txn_12",
"amount":
{
"currency": "CHF",
"value": "{$actualAmount}"
}
}]
}',
true);
And here is the echo of $body:
{ "sender_batch_header": { "email_subject": "SDK payouts test txn" }, "items": [ { "recipient_type": "EMAIL", "receiver": "{$email}", "note": "Your 1$ payout", "sender_item_id": "Test_txn_12", "amount": { "currency": "CHF", "value": "{$actualAmount}" } }] }
The variables I am talking about are $email and $actualAmount. I debugged it and they both have a value it just does not get added to the string. Can anyone help?