Answer the question
In order to leave comments, you need to log in
How to add a few words to each line (Reproduction)?
There are N lines of the form:
site.com/file.php
site2.net/file.php
site3.irg/file.php
?123
?abc
?777
site.com/file.php?123
site.com/file.php?abc
site.com/file.php?777
site2.net/file.php?123
site2.net/file.php?abc
site2.net/file .php?777
...
Answer the question
In order to leave comments, you need to log in
function crossConcat(array $someArray, array $otherArray) {
$concatenated = [];
foreach ($someArray as $someArrayElement) {
foreach ($otherArray as $otherArrayElement) {
$concatenated[] = $someArrayElement . $otherArrayElement;
}
}
return $concatenated;
}
$sites = ["site.com/file.php", "site2.net/file.php", "site3.irg/file.php"];
$paramStrings = ["?123", "?abc", "?777"];
var_dump(crossConcat($sites, $paramStrings));
/*
array(9) {
[0]=>
string(21) "site.com/file.php?123"
[1]=>
string(21) "site.com/file.php?abc"
[2]=>
string(21) "site.com/file.php?777"
[3]=>
string(22) "site2.net/file.php?123"
[4]=>
string(22) "site2.net/file.php?abc"
[5]=>
string(22) "site2.net/file.php?777"
[6]=>
string(22) "site3.irg/file.php?123"
[7]=>
string(22) "site3.irg/file.php?abc"
[8]=>
string(22) "site3.irg/file.php?777"
}
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question