Reference - PAD functions - afterLast


App: regression/framework - Page: expressions/a_built_in_function_is_found_in_its_own_case_only
PHP
HTML
expressions/a_built_in_function_is_found_in_its_own_case_only.pad
Result
[{echo DATE('Y', 0)}][{echo date('Y', 0)}][{echo 'a.b.c' | afterLast('.')}]


App: regression/framework - Page: functions/afterLast_drops_a_multi_character_delimiter_whole
PHP
HTML
functions/afterLast_drops_a_multi_character_delimiter_whole.pad
Result
{echo 'aXXbXXc' | afterLast('XX')}


App: regression/framework - Page: functions/afterLast_drops_the_delimiter_as_after_does
PHP
HTML
functions/afterLast_drops_the_delimiter_as_after_does.pad
Result
{echo 'hello/world/test' | afterLast('/')}


App: regression/framework - Page: functions/afterLast_with_no_delimiter_gives_the_value_back
PHP
HTML
functions/afterLast_with_no_delimiter_gives_the_value_back.pad
Result
{echo 'abc' | afterLast('/')}


App: regression/framework - Page: functions/an_empty_delimiter_is_found_last_at_the_end_afterLast_gives_nothing
PHP
HTML
functions/an_empty_delimiter_is_found_last_at_the_end_afterLast_gives_nothing.pad
Result
{echo 'abc' | afterLast('')}


App: regression/framework - Page: harness/the_answer_lives_beside_the_page
PHP
HTML
harness/the_answer_lives_beside_the_page.pad
Result
{echo '' | php:getSuiteWantFile('regression/pages', 'pairing') | afterLast('/')}


App: regression/framework - Page: helpers/strings_after_before_and_between_cut_as_the_pipes_do
PHP
helpers/strings_after_before_and_between_cut_as_the_pipes_do.php
HTML
helpers/strings_after_before_and_between_cut_as_the_pipes_do.pad
Result
<?php

$cuts
= [];

foreach ( [ [
'a/b/c', '/' ], [ 'a::b::c', '::' ], [ 'a/b/c', 'x' ], [ 'abc', '' ], [ 'één/twee/drie', '/' ],
[
NULL, 'x' ], [ 12345, 3 ], [ '0', '0' ] ] as [ $text, $search ] )
$cuts [] = [ padStrAfter ( $text, $search ), padStrAfterLast ( $text, $search ),
padStrBefore ( $text, $search ), padStrBeforeLast ( $text, $search ) ];

$r = json_encode ( $cuts, JSON_UNESCAPED_UNICODE );

$b = json_encode ( [
padStrBetween ( 'This is my name', 'This', 'name' ),
padStrBetween ( '[a] and [b]', '[', ']' ),
padStrBefore ( padStrAfter ( '[a] and [b]', '[' ), ']' ),
padStrBetween ( 'abc', 'x', 'y' ),
padStrBetween ( 'abc', 'a', 'y' ),
padStrBetween ( 'abc', '', '' ),
padStrBetween ( NULL, 'a', 'b' )
],
JSON_UNESCAPED_UNICODE );

$path = 'shop/orders/list.pad';

?>
{!r}
{!b}
[{$path | after('/')}|{$path | afterLast('/')}|{$path | before('/')}|{$path | beforeLast('/')}]
[{echo padStrAfter ( $path, '/' )}|{echo padStrAfterLast ( $path, '/' )}|{echo padStrBefore ( $path, '/' )}|{echo padStrBeforeLast ( $path, '/' )}]


App: regression/framework - Page: helpers/strings_the_slug_after_and_before_pipes_answer_as_they_did
PHP
helpers/strings_the_slug_after_and_before_pipes_answer_as_they_did.php
HTML
helpers/strings_the_slug_after_and_before_pipes_answer_as_they_did.pad
Result
<?php

$texts
= [ 'Crème Brûlée & Co.', ' Hello, World! ', 'a/b::c/d', '', '0', 'Ελληνικά & Ӄириллица', "tab\there", 'ÆØÅ æøå ß', '--a--b--', 'x/y' ];

?>
{texts}
[{$texts | slug}|{$texts | slug('_')}|{$texts | slug('')}|{$texts | after('/')}|{$texts | afterLast('/')}|{$texts | before('/')}|{$texts | beforeLast('/')}|{$texts | after('::')}|{$texts | beforeLast('zz')}]
{/texts}
[{echo 12345 | after(3)}|{echo 12345 | before(3)}|{echo 'abc' | after('')}|{echo 'abc' | afterLast('')}|{echo 'abc' | before('')}|{echo 'abc' | beforeLast('')}]


App: regression/pages - Page: catalog/functions
PHP
catalog/functions.php
HTML
catalog/functions.pad
Result
<?php

// The value the stripLow line cleans: printable letters around two control characters.

$catLow = "a\x01b\x02c";

?>
after:      {echo 'a/b' | after('/')}
afterLast: {echo 'a/b/c' | afterLast('/')}
before: {echo 'a/b' | before('/')}
beforeLast: {echo 'a.b.c' | beforeLast('.')}
between: {echo 17 | between(10, 66)}.
bold: {echo 'important' | bold}
close: {echo 'items' | close | ignore}
contains: {echo 12345 | contains('34')}.
cut: {echo 'banana' | cut('an')}
encodeHigh: {echo 'café' | encodeHigh}
exists: {echo 'hello/index.pad' | exists}.
html: {echo '<b>' | html}
in: {echo 'a' | in('a')}.
left: {echo 'abcdef' | left(2)}
like: {echo 'abc' | like('a%')}.
max_len: {echo 'abcdef' | max_len(4)}
mid: {echo 'abcdef' | mid(2, 3)}
nbsp: {echo 'hello world' | nbsp}
open: {echo 'items' | open | ignore}
optional: {$catNoSuch | optional}ok
range: {echo 50 | range(0, 100)}.
replace: {echo 'abc' | replace('b', 'x')}
right: {echo 'abcdef' | right(2)}
sanitize: {echo '<b>x</b>' | sanitize}
slashes: {echo "it's" | slashes}
stripLow: {echo $catLow | stripLow}
stripslashes: {echo "it's" | slashes | stripslashes}
tag: {echo 'items' | tag | ignore}
time: {echo 1702483200 | time('Y')}
timestamp: {echo 1702483200 | timestamp('Y')}
trim: {echo ' a b ' | trim}
ucwords: {echo 'hello world' | ucwords}
white: {echo 'a b' | white}