There is a code
<?php $a = array(1, 1, 2, 3, 4, 5, 15); $b = implode('', $a); $r = trim($b, '15'); echo $r; ?> Can you explain why the result will be 234?
There is a code
<?php $a = array(1, 1, 2, 3, 4, 5, 15); $b = implode('', $a); $r = trim($b, '15'); echo $r; ?> Can you explain why the result will be 234?
According to the description found on the Internet :),
There are no frills and colors. Specifies the character (s) to remove. Without this remove the following "" an ordinary space
The trim function removes the starting and ending characters according to the specified pattern as a string. For example, for a code snippet
$a = array(1, 1, 2, 3, 4, 5, 15); $b = implode('', $a); $r = trim($b, '14'); the initial '1' will be removed and the result will be
'234515' The characters '4' and '1', which are inside the string, will not be deleted, as they are not the starting or terminating character of the string.
And for this fragment, the code
$a = array(1, 1, 2, 3, 4, 5, 15); $b = implode('', $a); $r = trim($b, '15'); will be the result
'234' Source: https://ru.stackoverflow.com/questions/610872/
All Articles