Reputation: 80
i want to add a $var[5]which is containing string value to the {subscription_reference} part of the following url.
$url5 = $api_entry_point ."/subscription/{subscription_reference}/credentials";
it needs to be like this..
$url5 = $api_entry_point ."/subscription/0997f4ea6b6ca709/credentials";
I have tried different ways but all gone wrong.here are those
$url5 = $api_entry_point ."/subscription/'.$var[5].'/credentials";
$url5 = $api_entry_point ."/subscription/$var[5]/credentials";
Upvotes: 0
Views: 349
Reputation: 4313
You were pretty close, but got tangled up with your quotes ;-)
$url5 = $api_entry_point ."/subscription/'.$var[5].'/credentials";
Should be...
$url5 = $api_entry_point ."/subscription/" . $var[5] . "/credentials";
or you could have used:
$url5 = $api_entry_point ."/subscription/{$var[5]}/credentials";
Upvotes: 2
Reputation: 1423
The long way:
$url5 = $api_entry_point ."/subscription/".$var[5]."/credentials";
or
$url5 = $api_entry_point .'/subscription/'.$var[5].'/credentials';
They both work the same. But you need to use either "
or '
. Don't mix them.
The fanzy way:
$url5 = $api_entry_point ."/subscription/{$var[5]}/credentials";
This onyl works witht he "
. They check if anything in the string is a variable. So a normal "asd $var asd"
would understand $var
as a variable. But this won't work with special signs like [] or ()
and so on. Thus you have to put the variable in the {}
for the string to know which parts a pieces of variables.
Upvotes: 2
Reputation: 649
Try this :
$url5 = $api_entry_point."/subscription/".$var[5]."/credentials";
Upvotes: 5