Reference - Data handling - trim


App: manual - Page: miscellaneous/handling


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


App: regression/framework - Page: options/right_trims_only_the_back
PHP
HTML
options/right_trims_only_the_back.pad
Result
{data 'n'}
[1,2,3,4,5,6]
{/data}
{n trim=2, right}
{$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/trim_takes_one_off_each_end
PHP
HTML
options/trim_takes_one_off_each_end.pad
Result
{data 'n'}
[1,2,3,4,5,6]
{/data}
{n trim}
{$n},
{/n}


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


App: regression/framework - Page: sequence/trim_0_on_the_left_takes_nothing_off
PHP
HTML
sequence/trim_0_on_the_left_takes_nothing_off.pad
Result
{seqFixture trim=0, left}
{$seqFixture},
{/seqFixture}


App: regression/framework - Page: sequence/trim_0_on_the_right_takes_nothing_off
PHP
HTML
sequence/trim_0_on_the_right_takes_nothing_off.pad
Result
{seqFixture trim=0, right}
{$seqFixture},
{/seqFixture}


App: regression/framework - Page: sequence/trim_0_takes_nothing_off
PHP
HTML
sequence/trim_0_takes_nothing_off.pad
Result
{seqFixture trim=0}
{$seqFixture},
{/seqFixture}


App: regression/framework - Page: sequence/trim_on_the_left_only
PHP
HTML
sequence/trim_on_the_left_only.pad
Result
{seqFixture trim=2, left}
{$seqFixture},
{/seqFixture}


App: regression/framework - Page: sequence/trim_on_the_right_only
PHP
HTML
sequence/trim_on_the_right_only.pad
Result
{seqFixture trim=2, right}
{$seqFixture},
{/seqFixture}


App: regression/framework - Page: sequence/trim_takes_one_off_each_end
PHP
HTML
sequence/trim_takes_one_off_each_end.pad
Result
{seqFixture trim=1}
{$seqFixture},
{/seqFixture}


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}