Oihana PHP

delta.php

Table of Contents

Functions

delta()  : array{0: array, 1: array, 2: array}
Tells what left, what showed up, and what stayed, between two lists of identifiers.

Functions

delta()

Tells what left, what showed up, and what stayed, between two lists of identifiers.

delta(array<int, string> $before, array<int, string> $now) : array{0: array, 1: array, 2: array}

Meant to diff two runs of the same listing — e.g. the ids returned by a previous fetch versus the current one — and answer three questions at once : what closed, what appeared, and what stayed.

Parameters
$before : array<int, string>

The identifiers of a previous run.

$now : array<int, string>

The identifiers of this run.

Tags
example
use function oihana\core\arrays\delta;

[ $removed , $added , $kept ] = delta( [ 'a' , 'b' , 'c' ] , [ 'b' , 'c' , 'd' ] ) ;

print_r( $removed ) ; // [ 'a' ]
print_r( $added )   ; // [ 'd' ]
print_r( $kept )    ; // [ 'b' , 'c' ]
author

Marc Alcaraz (ekameleon)

since
1.3.0
Return values
array{0: array, 1: array, 2: array}

A 3-tuple [ $removed , $added , $kept ], each re-indexed from 0.

On this page

Search results