myArrayClass::__constructshould print "John" and "Smith" (no keys). Doesn't it?
$mySentenceis a string, so no
- You're not doing anything with the
- You can't go change serialized data. PHP's serialized data is weird (not like JSON), so you can't go around changing values. If you want to change values, use
json_encode() -> preg_replace() -> json_decode():
$mySentence = json_encode($sameArray); // assoc array in $mySentence = preg_replace('/a/', 'b', $mySentence); $otherArray = json_decode($mySentence, true); // assoc array out
Be careful though. Even json can be messed up if you replace it like that.