PhpDig.net

What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.




array_values

Name

array_values — Returns all values from an array.

Synopsis

array array_values(array);
array array:

Returns

Indexed array containing all values from another array; NULL on failure

Description

This function simply returns an indexed array in which each element is the corresponding element from array . The returned array is consecutively indexed starting from 0; all keys from the original array are ignored.

One use for this function is to quickly collapse an array that has had some elements unset using unset() into a freshly-ordered indexed array with no blank entries.

Version

PHP 4

Example

Example 37. Get the values from an array

$array = array(1, 2, 3, 5, 7, 11, 13, 17, 19, 23);
unset($array[3]);
unset($array[7]);
echo "Original array:\n";
print_r($array);
$arr2 = array_values($array);
echo "New array:\n";
print_r($arr2);

Output:
Original array:
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [4] => 7
    [5] => 11
    [6] => 13
    [8] => 19
    [9] => 23
)
New array:
Array
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 7
    [4] => 11
    [5] => 13
    [6] => 19
    [7] => 23
)



PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.