Reference - Data handling - splice


App: manual - Page: miscellaneous/handling


App: regression/framework - Page: options/a_negative_slice_or_splice_past_the_front_reaches_every_row
PHP
HTML
options/a_negative_slice_or_splice_past_the_front_reaches_every_row.pad
Result
{data 'n'}
[1,2,3,4,5]
{/data}
[{n slice='-9'}
{$n},
{/n}][{n splice='-7'}
{$n},
{/n}][{n slice='-2'}
{$n},
{/n}][{n splice='-2'}
{$n},
{/n}]


App: regression/framework - Page: options/a_slice_or_splice_length_of_zero_is_a_length
PHP
HTML
options/a_slice_or_splice_length_of_zero_is_a_length.pad
Result
{data 'n'}
[1,2,3,4,5]
{/data}
[{n slice='2|0'}
{$n},
{/n}][{n splice='2|0'}
{$n},
{/n}][{n slice='1|2'}
{$n},
{/n}][{n splice='1|2'}
{$n},
{/n}]


App: regression/framework - Page: options/rows_keyed_by_number_keep_their_keys_under_every_handler
PHP
options/rows_keyed_by_number_keep_their_keys_under_every_handler.php
HTML
options/rows_keyed_by_number_keep_their_keys_under_every_handler.pad
Result
<?php

// A set keyed by id - the keys are part of the rows, {&key} names them - and a list, which
// stays a list: numbered from 0 again after the handler.

$ks = [ 10 => [ 'n' => 3 ], 20 => [ 'n' => 1 ], 30 => [ 'n' => 2 ] ];
$xs = [ 'a', 'b', 'c' ];

?>
first:[{ks first=2}{&key},{/ks}] last:[{ks last=2}{&key},{/ks}] reverse:[{ks reverse}{&key},{/ks}] sort:[{ks sort='n'}{&key},{/ks}] splice:[{ks splice='1|1'}{&key},{/ks}] trim:[{ks trim}{&key},{/ks}] left:[{ks trim, left}{&key},{/ks}] random:[{ks random=3, orderly}{&key},{/ks}] list:[{xs reverse}{&key}{$xs},{/xs}][{xs last=2}{&key}{$xs},{/xs}][{xs splice='0|1'}{&key}{$xs},{/xs}]


App: regression/framework - Page: options/splice_from_a_position_for_a_length
PHP
HTML
options/splice_from_a_position_for_a_length.pad
Result
{data 'n'}
[1,2,3,4,5,6]
{/data}
{n splice='2|3'}
{$n},
{/n}


App: regression/framework - Page: options/splice_removes_them_instead
PHP
HTML
options/splice_removes_them_instead.pad
Result
{data 'n'}
[1,2,3,4,5,6]
{/data}
{n splice=2}
{$n},
{/n}


App: regression/pages - Page: catalog/handling
PHP
HTML
catalog/handling.pad
Result
dedup:   {data 'hN'}[1,1,2,2,3]{/data}{hN dedup}{$hN},{/hN}
reverse: {data 'hR'}[1,2,3]{/data}{hR reverse}{$hR},{/hR}
shuffle: {data 'hS'}[5]{/data}{hS shuffle}{$hS},{/hS}
slice: {data 'hL'}[1,2,3,4,5,6]{/data}{hL slice=2}{$hL},{/hL}
sort: {data 'hO'}[3,1,2]{/data}{hO sort}{$hO},{/hO}
splice: {data 'hP'}[1,2,3,4,5,6]{/data}{hP splice=2}{$hP},{/hP}
trim: {data 'hT'}[1,2,3,4]{/data}{hT trim=1}[{$hT}]{/hT}