functions.php

File

This file is part of php-fast-forward/iterators.

Description

This source file is subject to the license that is bundled with this source code in the file LICENSE.

Tags
copyright

Description

Copyright (c) 2025-2026 Felipe Sayão Lobato Abreu github@mentordosnerds.com

license

Description

https://opensource.org/licenses/MIT MIT License

Table of Contents

Functions

debugIterable()

Prints a debug representation of an iterable object.

 : void
Functions

Functions

debugIterable()

Prints a debug representation of an iterable object.

debugIterable( iterable<string|int, mixed>  $iterable[, string|null  $section = null]) : void

Description

This function iterates over a Traversable object and prints each key-value pair, along with an optional section title. If no section title is provided, the function uses the class name of the iterable object.

Example Usage:

Parameters
$iterable : iterable<string|int, mixed>

Description

the iterable object to debug

$section : string|null = null

Description

an optional title for the output section

Tags
example

Description

use FastForward\Iterator\debugIterable;
use ArrayIterator;

$iterator = new ArrayIterator(['a' => 1, 'b' => 2, 'c' => 3]);

debugIterable($iterator, 'Example Output');

Output:

=== Example Output ===

Length: 3
Output: [
  "a" => 1,
  "b" => 2,
  0 => 3,
]