PHP Classes

File: test/55__array_column.php

Recommend this page to a friend!
  Classes of ASCOOS CMS   PHP Backwards Compatibility Library   test/55__array_column.php   Download  
File: test/55__array_column.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Backwards Compatibility Library
Functions of newer PHP versions for older versions
Author: By
Last change: Updated to 1.1.3
Date: 23 days ago
Size: 2,322 bytes
 

Contents

Class file image Download
<?php
/**
 * __ _ ___ ___ ___ ___ ___ ____ _ __ ___ ___
 * / _` |/ / / __/ _ \ / _ \ / / / __/| '_ ` _ \ / /
 * | (_| |\ \| (_| (_) | (_) |\ \ | (__ | | | | | |\ \
 * \__,_|/__/ \___\___/ \___/ /__/ \___\|_| |_| |_|/__/
 *
 *
 *************************************************************************************
 * @ASCOOS-NAME : ASCOOS CMS 24' *
 * @ASCOOS-VERSION : 24.0.0 *
 * @ASCOOS-CATEGORY : Kernel (Frontend and Administration Side) *
 * @ASCOOS-CREATOR : Drogidis Christos *
 * @ASCOOS-SITE : www.ascoos.com *
 * @ASCOOS-LICENSE : [Commercial] http://docs.ascoos.com/lics/ascoos/AGL-F.html *
 * @ASCOOS-COPYRIGHT : Copyright (c) 2007 - 2023, AlexSoft Software. *
 *************************************************************************************
 *
 * @package : ASCOOS CMS - phpBCL
 * @subpackage : Example array_column Function
 * @source : /phpBCL/test/array_column.php
 * @version : 1.1.3
 * @created : 2023-07-07 07:00:00 UTC+3
 * @updated : 2024-10-22 07:00:00 UTC+3
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 */


require_once("../autoload.php");


// Array representing a possible record set returned from a database
$records = array(
    array(
       
'id' => 2135,
       
'first_name' => 'John',
       
'last_name' => 'Doe',
    ),
    array(
       
'id' => 3245,
       
'first_name' => 'Sally',
       
'last_name' => 'Smith',
    ),
    array(
       
'id' => 5342,
       
'first_name' => 'Jane',
       
'last_name' => 'Jones',
    ),
    array(
       
'id' => 5623,
       
'first_name' => 'Peter',
       
'last_name' => 'Doe',
    )
);
 

/**
 * ++ 5.5.0 ---- https://www.php.net/manual/en/function.array-column.php
 *
 * Run PHP 5.4.x
 */
$first_names = array_column($records, 'first_name');
print_r($first_names);

/*
RESULT
------

Array
(
    [0] => John
    [1] => Sally
    [2] => Jane
    [3] => Peter
)
*/

?>