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:
Date: 1 year ago
Size: 2,488 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 : **** - $release: 1.0 - $revision: 1 - $build: ****
 * @created : 2023-07-07 07:00:00 UTC+3
 * @updated :
 * @author : Drogidis Christos
 * @authorSite : www.alexsoft.gr
 */

define('ALEXSOFT_RUN_CMS', true);

$cms_path = str_replace('/phpBCL/test', '',str_replace('\\', '/', __DIR__));
 
require_once(
$cms_path."/phpBCL/src/coreCompatibilities.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
)
*/

?>