# Take out value from array

**URL:** https://forum.kirupa.com/t/take-out-value-from-array/71419
**Category:** Uncategorized
**Created:** [November 24, 2004, 5:27pm UTC](https://forum.kirupa.com/t/take-out-value-from-array/71419 "2004-11-24T17:27:41Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![cmd](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@cmd](https://forum.kirupa.com/u/cmd)
#### Post date: [November 24, 2004, 5:27pm UTC](https://forum.kirupa.com/t/take-out-value-from-array/71419/1 "2004-11-24T17:27:41Z")

</div>

hey there,

this is what i’m trying to do: i have an array full of id’s, such as  
Array[0] = 55;  
Array[1] = 56;  
Array[2] = 57;  
Array[3] = 58;  
etc

I have a link to remove a value from the array. I first search for the key then if found splice up the array to remove the value.

It works fine for all keys, except for 0. Argghh why?

-Chris

```php

if ($_GET['action'] == 'remove') {
if (in_array($_GET['pid'], $_SESSION['quotearray'])) {
$key = array_search($_GET['pid'], $_SESSION['quotearray']);
echo 'key: ' . $key;
if (($key != NULL)) {
	array_splice($_SESSION['quotearray'], $key, 1);
}
/*if (($key == 0) && (count($_SESSION['quotearray']) == 1) ) {
	unset($_SESSION['quotearray']);
	unset($_SESSION['finalquotearray']);
}*/ 
echo ' count ' . count($_SESSION['quotearray']); 
}
}

```
