Home php How to remove the first letter or sign?

How to remove the first letter or sign?

Author

Date

Category

Even you need 3 signs.


Answer 1, Authority 100%

Proper method: Use MB_Substr ()

$ input = 'in the corner mouse scrapes'; // Source string
$ Todelete = 3; // how many signs need to be removed
MB_INTERNAL_ENCODING ("UTF-8");
$ result = MB_Substr ($ input, $ Todelete); // Depth Screens Mouse

wrong Example:

$ input = 'in the corner mouse scrapes'; // Source string
$ Todelete = 3; // how many signs need to be removed
$ result = substr ($ input, $ Todelete); // corner scraper mouse

Because Cyrillic symbols – double-byte, “in” takes two bytes, the space is one. Therefore, not three symbols cut off, but only two.


Answer 2, Authority 19%

substr ($ text, 2); // Remove the first three characters

Answer 3

& lt;? php
$ Tekst = "ABSDEFGHI";
$ Tekst = substr ($ Tekst, 1.0);
Echo $ Tekst;
? & gt;

Answer 4

$ s = '12345678';
$ s = preg_replace ('/ ^ (.* )$/', '\ 1', $ s);
Echo "$ s \ n"; // Conclusion: 2345678
$ s = preg_replace ('/ ^/', '', $ s);
Echo "$ s \ n"; // Conclusion: 345678

Answer 5

$ matn = "salom";
$ Matn = Substr ($ Matn, 1);
Echo $ Matn;
// Displays: Alom
//or
$ Matn = "Salom";
$ Matn = Substr ($ Matn, 3);
Echo $ Matn;
// Displays: OM
// More option
$ Matn = "Salom";
$ Matn = Substr ($ Matn, -1);
Echo $ Matn;
// Displays: Salo
//or
$ Matn = "Salom";
$ Matn = Substr ($ Matn, 3);
Echo $ Matn;
// Displays: SA

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions