我使用了内爆'/‘,但在这种情况下,我想,最后两列iid和branch_id,比如==>>>>,iid."_".branch_id,我是说,对于最后两列,内爆将是'_’下划线,而不是'/‘斜杠,但对于前4列,它将是/,仅对于最后两列,它将是下划线。请帮我找出合适的解决方案。谢谢
echo "Creating Sitemap\n";
$switzerland= new Sitemap($switzerlandcodes_sitefile,["name","canton","city","iid","branch_id"],"UNKNOWN", $homeUrl.SWITZERLANDPATH.'/', SWITZERLANDTABLE);
$switzerland->createSitemap();
$files=array_merge($files,$switzerland->files);发布于 2021-11-23 16:22:51
在示例中,您没有向我们展示您的data或如何使用 implode function,但根据您问题的文本,我可以这样说:
array_chunk by length 3(名称,广州,城市)将数组拆分为基数组,并通过/implode参数将arrayimplode base与/一起进行_
$data = ['SomeName', 'Canton', 'AnotherCity', 'SomeIID', 'SomeBranchID'];
[$base, $param] = array_chunk($data, 3);
$result = implode('/',$base).'/'.implode('_',$param);结果是
SomeName/Canton/AnotherCity/SomeIID_SomeBranchIDhttps://stackoverflow.com/questions/70083766
复制相似问题