PHP简单修改/修正
我从某人那里得到了这段代码,创建动态面包屑几乎是完美的,但是有一点小故障,因为它在面包屑之前回显了两个分隔线:
$crumbs = explode("/",$_SERVER["REQUEST_URI"]);
foreach($crumbs as $crumb){
echo ucfirst(str_replace(array(".php","_"),array(""," "),'>' . $crumb));
}
它回显:
“>>内容>通用>文件”
我想要它做什么看起来像是
“content>common>1”,
如果有人能告诉我如何为数组中除最后一个(文件)之外的所有项目添加链接,我将不胜感激?
非常感谢大家,这个网站通过示例对我学习 php 帮助很大!
I got this code from someone, it's almost perfect to create a dynamic breadcrumb, but there just a little glitch because it echoes two dividers before the breadcrumb:
$crumbs = explode("/",$_SERVER["REQUEST_URI"]);
foreach($crumbs as $crumb){
echo ucfirst(str_replace(array(".php","_"),array(""," "),'>' . $crumb));
}
it echoes:
">>content>common>file"
what I want it to look like is
"content>common>1"
and also I will deeply appreciate if someone can tell me how can I add links for all the items in the array except the last one (file)?
Thank you so much everybody, this website really helped me a lot to learn php by examples!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许这样的事情会做:
//去掉空的部分
$crumbs = array_filter($crumbs);
已更新
Maybe something like this will do:
//get rid of empty parts
$crumbs = array_filter($crumbs);
Updated