Collection Library



( ZN >= 3.0.0 )

The Collection is derived from the Arrays library of the ZN Framework  and allows you to apply the methods of this library to a common library. It is ideal especially when more than one array method is used for a data.

# Methods


this data ( Array $ data )
Mixed get ( Void )

 

# Data ( ZN >= 3.0.0 )


The array to be processed is specified. This method should be specified immediately after Collection :: . It should be used as the top function.

Parameters

Array $ data Related series.
return this

Use of

$data  = ['foo', 'bar', 'baz'];
$data2 = ['zoo', 'coo'];

$collection = Collection::data($data)
                         ->merge($data2)
                         ->reverse()
                         ->removeLast()
                         ->addFirst(['xoo', 'yoo'])
                         ->get();

output($collection);
0 => string 'xoom' (length = 5 ) ,
1 => string 'Yoo (length = 5 ) ,
2 => string ' cooler ' (length = 5 ) ,
3 => string ' zoom ' (length = 5 ) ,
4 => string 'baz' (length = 5 ) ,
5 => string 'bar' (length = 5 )

 

# Get ( ZN >= 3.0.0 )


Used to get the result of the operation. This method should be used as the final (last) method .

Parameters

void
return Mixed

Use of

$data  = ['foo', 'bar', 'baz'];
$data2 = ['zoo', 'coo'];

$collection = Collection::data($data)
                         ->merge($data2)
                         ->reverse()
                         ->removeLast()
                         ->addFirst(['xoo', 'yoo'])
                         ->get();

output($collection);
0 => string 'xoom' (length = 5 ) ,
1 => string 'Yoo (length = 5 ) ,
2 => string ' cooler ' (length = 5 ) ,
3 => string ' zoom ' (length = 5 ) ,
4 => string 'baz' (length = 5 ) ,
5 => string 'bar' (length = 5 )