I have no idea if this is possible or if there is another way of doing it but any help would be appreciated. What I’m trying to do is turn off arrays individually. So I have this:
<?php
$arrLayout = array(
"section1" => array(
"wLibrary" => array(
"title" => "XBMC Library",
"display" => ""
),
"wControl" => array(
"title" => "Control",
"display" => ""
)
)
)
?>
What I want is this
<?php
$LibraryStatus='true'
$arrLayout = array(
"section1" => array(
if $LibraryStatus='true' (
"wLibrary" => array(
"title" => "XBMC Library",
"display" => ""
),
else blank.
if $ControlStatus='true' (
"wControl" => array(
"title" => "Control",
"display" => ""
)
)
)
?>
If its false then it will also be blank obviously. Is it possible to have an if then inside an array controlling another array? If so how would it work? This is just part of the array there are more options and sections I just took those out for simplicity as its easy to scale once I understand how to do it once.
Yes, this is possible using a certain shorthand:
It works like this:
is equal to
If you use this shorthand it will always return the output, so you can put it between brackets and put it inbetween the array.
http://codepad.org/cxp0M0oL
But for this exact situation there are other solutions as well.