Reference - Parms functions - right


App: manual - Page: fragments/expressions_31


App: regression/framework - Page: functions/a_cut_from_the_end_of_a_long_text_with_a_broken_byte_counts_code_points
PHP
functions/a_cut_from_the_end_of_a_long_text_with_a_broken_byte_counts_code_points.php
HTML
functions/a_cut_from_the_end_of_a_long_text_with_a_broken_byte_counts_code_points.pad
Result
<?php

// A text with a byte that is no UTF-8, far before its end: it is cut in code points, as
// the same text is when the byte stands near the end.

$tail = "ab\u{1F1F3}\u{1F1F1}e\u{301}";
$long = "\xFF" . str_repeat ( 'a', 5000 ) . $tail;
$short = "\xFF" . str_repeat ( 'a', 10 ) . $tail;

?>
[{echo $long | right(1) | php:bin2hex(@)}][{echo $long | right(2) | php:bin2hex(@)}][{echo $long | substr(-3, 1) | php:bin2hex(@)}][{echo $short | right(1) | php:bin2hex(@)}]


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


App: regression/framework - Page: functions/cuts_count_characters_not_bytes
PHP
HTML
functions/cuts_count_characters_not_bytes.pad
Result
{echo 'Zoë Müller' | left(3)}|{echo 'Zoë Müller' | right(6)}|{echo 'Zoë Müller' | mid(3, 3)}|{echo 'Zoë Müller' | substr(2, 3)}|{echo 'Zoë Müller' | max_len(3)}


App: regression/framework - Page: functions/right
PHP
HTML
functions/right.pad
Result
{echo 'Hello World' | right(5)}


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


App: regression/framework - Page: functions/right_past_the_end_gives_all_of_it
PHP
HTML
functions/right_past_the_end_gives_all_of_it.pad
Result
{echo 'ab' | right(5)}


App: regression/framework - Page: functions/the_cutting_functions_count_the_characters_a_reader_sees
PHP
functions/the_cutting_functions_count_the_characters_a_reader_sees.php
HTML
functions/the_cutting_functions_count_the_characters_a_reader_sees.pad
Result
<?php

$flag
= "\u{1F1F3}\u{1F1F1} NL";
$nfd = "e\u{0301}cole";
$fam = "a\u{1F468}\u{200D}\u{1F469}\u{200D}\u{1F467}";

?>
[{echo $flag | left(1) | php:bin2hex(@)}][{echo $nfd | left(1) | php:bin2hex(@)}][{echo $fam | right(1) | php:bin2hex(@)}][{echo $nfd | mid(2, 2)}][{echo $flag | max_len(1) | php:bin2hex(@)}][{echo $nfd | substr(1)}][{echo $nfd | truncate(3, '.') | php:bin2hex(@)}]


App: regression/framework - Page: functions/the_cutting_functions_keep_a_character_whole_at_the_end_of_a_long_text
PHP
functions/the_cutting_functions_keep_a_character_whole_at_the_end_of_a_long_text.php
HTML
functions/the_cutting_functions_keep_a_character_whole_at_the_end_of_a_long_text.pad
Result
<?php

// Past 4096 bytes right() and substr() from the end read a window at the end of the text,
// not the whole of it: a run of flags, whose pairs count from the run's start, and an
// accent written apart must come out whole there too.

$flags = str_repeat ( "\u{1F1F3}\u{1F1F1}", 3001 );
$accent = str_repeat ( "e\u{0301}", 3000 ) . "ab";

?>
[{echo $flags | right(1) | php:bin2hex(@)}][{echo $flags | substr(-2, 1) | php:bin2hex(@)}][{echo $accent | right(3) | php:bin2hex(@)}][{echo $accent | mid(3000, 1) | php:bin2hex(@)}][{echo $accent | truncate(3, '') | php:bin2hex(@)}]


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}