我试图从数组中删除键.
这是我从print_r($ cats)得到的东西;
Array
(
[0] => <a href="/website/index.php/Category:All" title="Category:All">All</a> > <a href="/website/index.php/Category:Computer_errors" title="Category:Computer errors">Computer errors</a> > <a href="/website/index.php/Category:HTTP_status_codes" title="Category:HTTP status codes">HTTP status codes</a> > <a href="/website/index.php/Category:Internet_terminology" title="Category:Internet terminology">Internet terminology</a>
[1] =>
<a href="/website/index.php/Category:Main" title="Category:Main">Main</a>
)
Run Code Online (Sandbox Code Playgroud)
我试图用它来从数组中删除"Main"类别
function array_cleanup( $array, $todelete )
{
foreach( $array as $key )
{
if ( in_array( $key[ 'Main' ], $todelete ) )
unset( $array[ $key ] );
}
return $array;
}
$newarray = array_cleanup( $cats, array('Main') );
Run Code Online (Sandbox Code Playgroud)
仅供参考我是PHP的新手...显然我看到我犯了错误,但我已经尝试了很多东西而且他们似乎没有工作
关于我如何能够获得圆角的任何想法都可以使用多个边框?盒子将是动态的,取决于盒子里的内容,所以我不能添加静态宽度或高度.
body { background: #d2d1d0; }
#box {
border-radius: 15px;
background: #f4f4f4;
border: 1px solid #bbbbbb;
width: 100%;
height: 100%;
margin: 10px auto;
position: relative;
}
DIV#box, #box:before, #box:after {
-moz-border-radius: 15px;
border-radius: 15px;
}
#box:before {
border-radius: 15px;
border: 1px solid white;
width: 99%;
height: 94%;
content: '';
position: absolute;
}
#box:after {
border-radius: 15px;
content: '';
position: absolute;
border: 1px solid #bbbbbb;
width: 98%;
height: 90%;
left: 1px; top: 1px;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div id="box">Hello World!!!!<br>THIS IS SECOND LINE …
Run Code Online (Sandbox Code Playgroud) 我无法使用此代码
if ($title != 'Main' || $nSpace == 56 || $nSpace == 30 && $ifHome != 361)
Run Code Online (Sandbox Code Playgroud)
所以我决定使用这段代码
if ($title != 'ArticleCategories' || $nSpace == 1)
if ($nSpace == 0 && $ifHome != 1)
Run Code Online (Sandbox Code Playgroud)
所以,我现在想知道如何才能将这两条线放入一条线以便它起作用?我知道如何获得多个或|| 语句分为一行而不是或|| 和&&和陈述在一起.
这就是我目前正在使用的
<?php $sidebar = $this->data['sidebar'];
$lastKey = array_pop(array_keys($sidebar));
$sidebar = $this->data['sidebar'][$lastKey]; ?>
<?php foreach($sidebar as $key => $item) { ?>
<li id="<?php echo Sanitizer::escapeId( "pt-$key" ) ?>"<?php
if ($item['active']) { ?> class="active"<?php } ?>><a href="<?php echo htmlspecialchars($item['href']) ?>"><?php echo htmlspecialchars($item['text']) ?></a></li>
<?php } ?>
Run Code Online (Sandbox Code Playgroud)
这是我得到的(http://pastebin.com/t6Y2ZtMF)当我print_r($sidebar)
; 我想得到最后一个数组,它是类别并将其转换为链接.
我是php的新手,所以我的方法可能是错的,即使它有效.我有一个正确的方法来拉出类别数组或上面的代码是好的,因为它是?