PHP code example of coercive / iterator

1. Go to this page and download the library: Download coercive/iterator library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

coercive / iterator example snippets


foreach (new MbStrIterator('string') as $i => $chr) {
	echo "$i => $chr \n";
}

$examples = array(
    1 => array(
        'id' => 'abcd',
    ),
    2 => array(
        'id' => 'ABCD',
    ),
    3 => array(
        'id' => 'aabcd',
    ),
    4 => array(
        'id' => 'aAbcd',
    ),
    5 => array(
        'id' => 'AAbcd',
    ),
);

# Instantiate with data
$array = new Sort($examples);

# [optional] Set case-insensitive if useful
$array->insensitive(true);

# [optional] Set targeted key level
$array->level(1);

# Sort ASCENDING
$sorted = $array->asc('id');

# Sort DESCENDING
$sorted = $array->desc('id');