implode(',', $a);
I want to attach the $q
variable in front of the $a
so like this
implode(',', $q.$a);
But that doesn`t work. How can i put 2 variables in a implode function?
$a
is an array with domain names like "com, org" and $q
is the text (string) you type in before the domain names will appear.
I get the following error:
invalid argument passed in line..
Whole code:
$a = ['nl','net','com','co'];
$q = $_REQUEST["q"];
$domain = explode(".", $q);
$ext = @$domain[1] ?: ' ';
if (empty($ext)) {
echo implode(',',$a);
} else if (in_array($ext, $a)) {
echo $q;
} else {
$r = [];
foreach ($a as $x) {
if (strstr($x, $ext)) {
$r[] = $x;
}
}
echo (count($r)) ? implode(',',$r) : implode(',',$a);
}