PHP Array and unset function

I have an array like this.

    Array
    (
        [0] => Array
            (
                [email] => abc@gmail.com
                [timestamp] => 2013-05-03 09:20:01
            )

        [1] => Array
            (
                [email] => def@gmail.com
                [timestamp] => 2013-05-03 09:20:23
            )

        [2] => Array
            (
                [email] => ghi@gmail.com
                [timestamp] => 2013-05-03 09:20:43
            )

    )

I want this to be as simple as like this.

    Array
    (
        [0] => abc@gmai1.com
        [1] => def@gmail.com
        [2] => ghi@gmail.com
    )

I have tried unset function but it still doesn't work as i expected.

I am not big into array concept and hence my stupid questions !!! :(

Answers


foreach($foo as $key=>$value)
{
  $foo[$key] = $value['email'];
}

I think that it'd be better to use array_map instead of unset:

function filter($x)
{
    return $x['email'];
}

$emails = array_map('filter', $your_array);

This basically will map your input array into output array using filter function.


Need Your Help

Hive: can't fill index

hadoop indexing hive hiveql

I'm using Hive 14.0 and have a challenge to index tables. If I want to build an index without DEFERRED REBUILD, Hive do not create an index-table for me. If I use it with DEFERRED REBUILD an index-...

Select Value From Combobox And Add to Sql Database using VB in VS 2010

sql vb.net visual-studio-2010 combobox

I am new to VB and VS 2010. I have a problem.I have created a database.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.