array issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

array issue

Post by itsmani1 »

i want to remove element form array and what i know is '14937777' or '14547812', that's all, can i remove array form main array?

Code: Select all

Array
(
    [14547812] => Array
        (
            [0] =>  
            [1] => Orch
            [2] => Z
            [3] => 245
        )

    [14937777] => Array
        (
            [0] =>  
            [1] => 140
            [2] => I
            [3] => 685
        )
)
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

it simply unseats whole array:
you can see there are two array in one array, i want to remove one of them not the whole array.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Please, take a closer look at example 1 of http://de3.php.net/unset[quote]// destroy a single element of an array[/quote]
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post by dibyendrah »

Code: Select all

<?php
$var = array(0=>array('x', 'y', 'z'), 1=>array('a', 'b', 'c'));
print_r($var);
unset($var[0][0]);
print_r($var);
?>
Output :

Code: Select all

Array
(
    [0] => Array
        (
            [0] => x
            [1] => y
            [2] => z
        )

    [1] => Array
        (
            [0] => a
            [1] => b
            [2] => c
        )

)
Array
(
    [0] => Array
        (
            [1] => y
            [2] => z
        )

    [1] => Array
        (
            [0] => a
            [1] => b
            [2] => c
        )

)
Hope you have an idea now. :wink:
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post by itsmani1 »

thanks dibyendrah.
Post Reply