Reference - Parms functions - left


App: manual - Page: fragments/expressions_30


App: regression/framework - Page: expressions/a_built_in_written_as_a_call_reads_its_first_argument
PHP
HTML
expressions/a_built_in_written_as_a_call_reads_its_first_argument.pad
Result
{set $s = 'hello'}[{echo trim('  a  ')}][{echo upper($s)}][{echo left($s, 2)}][{if upper($s) eq 'HELLO'}T{else}F{/if}][{echo 'x' . upper($s)}][{echo date('Y', 0)}][{echo $s | replace('l', upper('x'))}][{echo substr($s, 0, 3)}][{echo $s | left(2)}][{$s | left(3)}]


App: regression/framework - Page: expressions/a_call_in_a_list_item_keeps_the_items_before_it
PHP
HTML
expressions/a_call_in_a_list_item_keeps_the_items_before_it.pad
Result
{echo php:json_encode([3, upper('x'), [1, 2], trim(' y ')])} {echo php:json_encode(['a' => 1 ? 'b' : 'c', 'd' => left('xyz', 2)])}


App: regression/framework - Page: expressions/a_date_object_is_its_text_to_operators_and_text_pipes
PHP
expressions/a_date_object_is_its_text_to_operators_and_text_pipes.php
HTML
expressions/a_date_object_is_its_text_to_operators_and_text_pipes.pad
Result
<?php

// A date object a page's PHP leaves is its text - Y-m-d H:i:s, as {$d} writes it - to an
// operator, a pipe that takes text and a query value: compared as an object it stood above
// every string, and | upper, . and {?d} ended the page on a TypeError.

$d = new DateTime ( '2020-01-02 03:04:05' );

?>
lt[{if $d lt '2030-01-01'}Y{else}N{/if}] gt[{if $d gt '2030-01-01'}Y{else}N{/if}] eq[{if $d eq '2020-01-02 03:04:05'}Y{else}N{/if}] [{$d | upper}] [{$d | left(10)}] [{echo $d . ' UTC'}] [{$d | date('Y')}] [{?d}]


App: regression/framework - Page: expressions/a_pipe_in_brackets_after_a_call_with_arguments_runs_every_part
PHP
HTML
expressions/a_pipe_in_brackets_after_a_call_with_arguments_runs_every_part.pad
Result
{echo (mid('hello', 1, 2) | ucfirst)} {echo (php:max(1, 2, 3) | + 1)} {echo upper(('ab' | replace('a', 'x')))} {echo ('x' | left(2) | . '!')}


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

$items
= [ [ 'name' => 'Zoë' ], [ 'name' => 'Tom & Jerry' ], [ 'name' => "O'Neil" ] ];

?>
1[{items}{$name} {/items | upper}] 2[{items}{$name} {/items | truncate(8)}] 3[{items}{$name} {/items | left(4)}]


App: regression/framework - Page: functions/a_field_cut_after_a_multibyte_letter_is_not_blanked
PHP
HTML
functions/a_field_cut_after_a_multibyte_letter_is_not_blanked.pad
Result
{set $n = 'Zoë Müller'}{$n | left(3)}


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


App: regression/framework - Page: functions/a_null_handed_along_a_pipe_chain_is_empty_to_the_next_function
PHP
HTML
functions/a_null_handed_along_a_pipe_chain_is_empty_to_the_next_function.pad
Result
[{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | trim}][{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | html}][{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | left(3)}][{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | replace('a', 'b')}][{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | url}][{echo 'https://example.com/page' | php:parse_url(@, PHP_URL_QUERY) | default('none')}]


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/extraction_feeding_a_chain
PHP
HTML
functions/extraction_feeding_a_chain.pad
Result
{echo 'hello world' | left(5) | upper}


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


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


App: regression/framework - Page: functions/left_past_the_end_gives_all_of_it
PHP
HTML
functions/left_past_the_end_gives_all_of_it.pad
Result
{echo 'ab' | left(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(@)}]