Receipt of the substrate after a defined set of symbols (e.g.:sen)
-
How to get part of the line after
!sen
? After!sen
may be any value from the letters/digits and examples:!senword
!sen123
!senword123
I'm doing
$sen = explode("!sen", $s);
But what's the fastest way?
-
If I understood your question correctly, you could use your function. http://php.net/manual/ru/function.substr.php
<?php /** * В данной функции параметр $fromChar не обязательный, * по умолчанию он указывает на позицию символа после которого * нужно будет вырезать строку, он пригодится в том случае * когда Вы решите отбросить не !sen а допустим !se или !senw */ function foo($string, $fromChar=4) { return substr($string, $fromChar); } // ну и проверка echo foo('!senword'); // выведет word echo foo('!sen123'); // выведет 123
$testString = foo('!senword123', 3);
echo $testString; // выведет nword123
?>