explode和substr_count不能与“ ”一起使用

Hi guys why i can't explode or count character with " " in my string?

$input = 'sv_privateClientsForClients\\0\\sv_pure\\0
0 0 0 0 999 \"DarkGhost\"\"spectator\"

0 0 0 0 999 \"MaximuM\"\"spectator\"

",';

$str = substr($input, strpos($input, "sv_pure") + 11, -7);

$x = explode('

', $str);    //not work
$c = substr_count($str,"

"); // not work
$input = 'sv_privateClientsForClients\\0\\sv_pure\\0
0 0 0 0 999 \"DarkGhost\"\"spectator\"

0 0 0 0 999 \"MaximuM\"\"spectator\"

",';
$str = substr($input, strpos($input, "sv_pure") + 11, -7);
$x = explode('

', $str);   
$c = substr_count($str,'

'); //changed double quotes to single quotes

Try to replace ' ' with a "ABC" using str_replace() function and then explode string with "ABC"

Do you want a pair of newline characters, or do you literally want the string in the output? The answer hinges on the answer to that question, but in either case by far the most important thing you can do is be consistent with the style of quotes you use.

PHP strings can be in single quotes (''), or in double quotes ("") as well as a couple of other formats that we won't get into for the sake of simplicity. Single quotes and double quotes are not the same:

  • Double quote strings support the inclusion of a number of control characters ( for newlines, \t for tabs, etc), while single quote strings support almost no control characters. If you want a newline in a single quote string you have to literally put a newline into the string.
  • Double quote strings support variable substitution (if you put a named variable in the string then the contents of the named variable will be substituted when you echo the string out).

The fact that your code is using single-quoted strings for some things and double-quoted strings for others means that your strings are inconsistent. " " will not match ' ' because they are not the same thing.

If you intend for to mean a pair of newlines then you should simply just use double-quoted strings throughout.

If you intend for to mean the literal string ' ' then you can either use single-quoted strings throughout, or you could use the escape sequence \\ which tells PHP that the next character is not a control character but a literal backslash. To get with a double-quoted string you need to enter it into your code as "\ \ "