1

I have a file called layout.php which contains

<?php
$arrLayout = array(
    "section1" => array(

        "wXBMCLibrary" => array(
            "title" => "XBMC Library",
            "display" => ""
        ),
        "wRecentMovies" => array(
            "title" => "Recent Movies",
            "display" => ""
        ),
        "wRecentTV" => array(
            "title" => "Recent TV",
            "display" => ""
        )
    )
    );
?>

What I would like to be able to do is remove any part, for example if I say remove wXBMCLibrary it must remove all of the below

 "wXBMCLibrary" => array(
        "title" => "XBMC Library",
        "display" => ""
    ),

Is this at all possible? Would you be able to unset the whole piece? What would the coding be? Regards

1
  • You can't automatically remove all 'below' an element in PHP, but you can loop over the array and manually delete elements after finding the one you want. Commented Aug 12, 2011 at 16:02

2 Answers 2

1
unset($arrLayout['section1']['wXBMCLibrary']);
Sign up to request clarification or add additional context in comments.

1 Comment

Could I use variables in place of 'section1' and 'wXBMCLibrary'
0

This is completely possible through the usage of unset() within PHP. The unset() function will remove the item that you specify, so if you specify unset($arrLayout['section1']['wXBMCLibrary']); then that will remove the array with the index of 'wXBMCLibrary'.

PHP - Unset() function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.