41 of 110 menu

Trimming a String in PHP

To trim a string in PHP, use the substr function. It extracts and returns a substring from a string. The original string itself is not modified. The numbering of string characters starts from zero. See the example:

<?php $arr = substr('abcdef', 1, 3); echo $arr; ?>

Code execution result:

'bcd'
English
БеларускаяEspañolРусский
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline