This is what kind of situation!!!
For example:
$str = "Abcadef";
$strone = $str [0];
for ($i =0; $i<>
if ($strone = = $str [$i]) {
$str [$i]= "";
}
}
Var_dump ($STR);
Shows:
String (7) "Bcdef";
Excuse me, why is this string still 7 lengths, there is no way to make him into 5 lengths,
------Solution--------------------
$str = "Abcadef";
$strone = $str [0];
$r = ";
for ($i =0; $i
<>
if ($strone! = $str [$i]) {
$r. = $str [$i];
}
}
$str = $r;
Var_dump ($STR);
------Solution--------------------
Solution upstairs everybody said it, but to avoid you repeating it, say something about the theory
The program appears to be "reasonable," but it's actually wrong, and the key is the way PHP cores store variables
PHP has a string variable assigned to the length of the record, to change the length of the need to re-assign value
$str [x]= ' This form does not re-assign a value to a string variable, because ' is a null byte and can only be used for an empty string
It is possible to replace a non-empty byte
For details, please refer to the understanding of PHP kernel