note 38635 deleted from function.array-search by nlopess
| From: | nlopess@php.net | Date: | Wed, 31 Dec 2003 09:39:16 +0000 |
| Subject: | note 38635 deleted from function.array-search by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-62714@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster@anjungcafe.net(izhan khalib)
----
Example to remove target item in array.
previouspage.php
---------------
<?php
session_register('debit');
$debit[0]="0";
?>
You need to register the '$debit' session in previous page and assign it to
'0',
removepage.php
------------------
<?php
session_start();
//debit is an array in session
//$ledger_no is value in array.
//for example ledger no='1'
$ledger_no="1";
array_push($debit, $ledger_no);
$ledger_no="3";
array_push($debit, $ledger_no);
$ledger_no="5";
array_push($debit, $ledger_no);
//removing item from array print_r($debit);
//remove item which is valued by 3
$ledger_no="3";
$debit=popArrayItem($debit,$ledger_no);
//you can print_r to get a result.
//print_r($debit);
?>
<?php
//remove an array
function popArrayItem($whatArrayName,$whatVariable){
//pop engine to pop out(delete) target item in array sequence manner
//get the associate key
$theKey=array_search ($whatVariable, $whatArrayName);
//destroy or remove associates key
unset($whatArrayName[$theKey]);
return $whatArrayName;
}