Home php How to steak the string after a specific symbol

How to steak the string after a specific symbol

Author

Date

Category

Hello, is there such a PHP function or an expression that would pace a period in a variable after the sign = (string variable and if there is = it took place, but the other part before = did not parse, thank you very much) I can not find answers on the Internet.


Answer 1, Authority 100%

Dana row and work with a string:

$ str = 'str = 1';
$ result = substr (STRSTR ($ str, '='), 1, strlen ($ STR));
Echo $ Result; # Will out: 1

or so:

$ str = 'str = 1';
$ result = substr ($ STR, STRPOS ($ str, '=') + 1, strlen ($ STR));
Echo $ Result; # Will out: 1

Answer 2, Authority 114%

Try (simplified without checks):

$ string_array = explode ("=", $ string);
echo $ string_array [1]; // line after equal

Answer 3, Authority 29%

$ str = "= 1 = 2 = 3 = 4";
  preg_match_all ('| = (. +?) | is', $ str, $ Match);
  VAR_DUMP ($ Match [1]);
 Array (4) {
   [0] = & gt;
   String (1) "1"
   [1] = & gt;
   String (1) "2"
   [2] = & gt;
   String (1) "3"
   [3] = & gt;
   String (1) "4"
  }

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