Search code examples
phpvariablesglobal-variables

Unset same variable from different array


I need to unset a variable from $_GET, $_POST and $_REQUEST.

As if now I do it simply by calling unset three time.

unset( $_GET['add-to-cart'] );
unset( $_POST['add-to-cart'] );
unset( $_REQUEST['add-to-cart'] );

Is there any simple code for doing this ?

Right now creating a custom function only seem to be the alternative to me, Is there any single line code for this ?

Thank You


Solution

  • You could put it in one line:

    unset($_GET['add-to-cart'], $_POST['add-to-cart'], $_REQUEST['add-to-cart']);