02 Votes

PHP: Remove first Character from String

Question by Guest | 2015-06-08 at 09:44

I would like to cut off the first character from the front of an arbitrary string using PHP.

This first character can be an arbitrary letter or an arbitrary number and also the length of the string can vary.

Does someone know any PHP function for this?

ReplyPositiveNegative
0Best Answer0 Votes

You can use the PHP function substr() for this.

Here is a small example:

$s = 'abc';

echo substr($s, 1);  // bc

We have the string "abc" and using substr() we are cutting off the first letter. Therefore, the result will be "bc".

When using another number instead of 1, the corresponding number of characters will be removed instead.
2015-06-09 at 12:21

ReplyPositive Negative
Reply

Related Topics

HTACCESS: Simplify URL

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.