Reputation:
I want to add multiple link in params.php . Is it possible to do so ?
Current view of my params in yii2 .
<?php
return [
"api_link" => "http://example.com" ,
];
I want to add multiple link in it
Ex:
<?php
return[
"api_link" => "http://example.com" & "http://www.example.com"
];
Is it possible to do so ? I tried but unable to succeed on this attempt .
Any lead over this will really be helpful.
Upvotes: 1
Views: 184
Reputation: 133380
You can store in an array
<?php
return [
"api_link" => [
"http://example.com",
"http://example.com",
]
];
....
and for accessing you must iterate over it
$myaArray = [
"api_link" => [
"http://example.com",
"http://www.example.com",
]
];
foreach( $myArray['api_link'] as $key =>$value){
echo $value;
}
or
echo $myArray['api_link'][0];
Upvotes: 1
Reputation: 430
You can set array for each params :
<?php
return [
"api_link" => [
"http://example.com",
"http://example.com",
]
];
Upvotes: 3
Reputation: 17
i don't understand what you want. But you can try by multidimensional array.
$arrayname = array(
'url1' => 'nokibrokes.com',
'url2' => 'example.com'
);
return $arrayname;
Upvotes: 1