我有这个数组:
$final[0] = "San"
$final[1] = "Antonio"
$final[2] = "de"
$final[3] = "Areco"
$final[4] = 1200
$final[5] = 1231
$final[6] = "San"
$final[7] = "Martin"
$final[8] = "de"
$final[9] = "Andes"
$final[10] = 1200
$final[11] = 1231
$final[12] = "Carlos"
$final[13] = "Casares"
$final[14] = 1200
$final[15] = 1231
我需要将所有字母数字值组合成一个值,并将数字保留在一个值上。
这就是我正在尝试的,但我不能让它工作,如果名字是两个词长似乎工作正常,但三个或更多词就像我'想念'第一个。
它应该是这样的:
$final[0] = "San Antonio de Areco"
$final[1] = 1200
$final[2] = 1231
$final[3] = "San Martin de Andes"
$final[4] = 1200
$final[5] = 1231
$final[6] = "Carlos Casares"
$final[7] = 1200
$final[8] = 1231
你能给我一个提示吗?
谢谢!
foreach ($final as $c => $v) {
if (ctype_alpha($v)) {
$vuelta1 = ($c+1);
if (ctype_alpha($final[$vuelta1])) {
$final[$vuelta1] = $v." ".$final[$vuelta1];
unset($final[$c]);
} else {}
}
}