如何重复一个字符串' x'给出的时间' y'参数

时间:2016-05-27 13:13:38

标签: string generator combinations

我需要重复19个字符串,如下所示生成站点地图; mysite.com/especialidad/policia。我需要将它与60个参数结合起来,例如?region = madrid,?region = barcelona。

所以我需要生成19 * 60(1140),如mysite.com/especialidad/policia/​​?region=barcelona。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

<强> PHP

$myArray = ( "madrid", "barcelona", "...");
foreach($myArray as $e) {
   echo "mysite.com/especialidad/policia?region=".$e;
}

<强>爪哇

String[] myArray = {"madrid", "barcelona", "..."};
for (int i=0; i<myArray.length; i++) {
   System.out.println("mysite.com/especialidad/policia?region="+myArray[i]);
}

<强>的Python

myArray = ['madrid', 'barcelona', '...']
for e in array:
   print 'mysite.com/especialidad/policia?region=',e

<强>的JavaScript

var index;
var myArray = ["madrid", "barcelona", "..."];
for (index = 0; index < myArray.length; index++) {
    console.log('mysite.com/especialidad/policia?region='+a[index]);
}

<强>的Perl

my @myArray = ("madrid", "barcelona", "...");
foreach (@myArray) {
  print "$_<br>\n";
}