N
N
Nick Bukovskiy2018-02-01 12:14:14
PHP
Nick Bukovskiy, 2018-02-01 12:14:14

How to check the first 3 characters in a string for a match?

How to check the first 3 characters in a string for a match and if they match the given value - remove them from the string?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Stimulate, 2018-02-01
@sonterix

preg_replace('/^'.$var1.'/siu', '', $var2);

D
Dmitry Kim, 2018-02-01
@kimono

preg_replace("/^abc(.*)/uim", "$1", $text);

A
Alexander Aksentiev, 2018-02-01
@Sanasol

if the characters are known, then just do a str replace.
If they are, then they will be deleted, if not, then nothing will happen.
You don't really need to cut the regulator.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question