Page 1 of 1

Array unset

Posted: Mon Dec 11, 2006 8:52 pm
by Shendemiar

Code: Select all

$A = array (
  'Some' => 'zzzz',
  'Thing' => 'SSSS',
  'B' => 
  array (
    '1:1:1' => 0,
    '2:2:2' => 0,
    '3:3:3' => 0,
How come

Code: Select all

$R = $_GET['F']       (='2:2:2')

unset($A['B'][$R]);

var_export $A
...
    '1:1:1' => 0,
    '3:3:3' => 0,
    '' => 0,

Posted: Mon Dec 11, 2006 9:19 pm
by Shendemiar
Using array pop i can get rid of it, but its weird.

Posted: Mon Dec 11, 2006 11:06 pm
by feyd
I have no idea what problem you are having because you haven't explained anything. Please do so.

Posted: Tue Dec 12, 2006 1:21 am
by volka
I cannot reproduce the "error".

Code: Select all

<?php
$A = array (
		'Some' => 'zzzz',
		'Thing' => 'SSSS',
		'B' =>array (
				'1:1:1' => 0,
				'2:2:2' => 0,
				'3:3:3' => 0
			)
	);

$R = '2:2:2';
unset($A['B'][$R]);
var_export($A);
prints

Code: Select all

array (
  'Some' => 'zzzz',
  'Thing' => 'SSSS',
  'B' => 
  array (
    '1:1:1' => 0,
    '3:3:3' => 0,
  ),
)

Posted: Tue Dec 12, 2006 1:33 am
by Ind007
To Shendemiar
I think, we cannot expect unset() to make the key value somthing like space or null