<?php
echo "<h3>1) array as string</h3>";
$sa = '["item1","item2","item3"]';
echo "<h3>2) array as string decoded</h3>";
echo "<h3>3) array as string decoded, then encoded again. <small>(Note it's the same as the original string)</small></h3>";
echo "<h3>4) Unset decoded</h3>";
echo "<h3>5) Encode unset array. <small>(Expecting it to look like original string minus the unset value)</small></h3>";
echo "<h3>6) Decode Encoded unset array</h3>";
PD9waHAKCmVjaG8gIjxoMz4xKSBhcnJheSBhcyBzdHJpbmc8L2gzPiI7CiRzYSA9ICdbIml0ZW0xIiwiaXRlbTIiLCJpdGVtMyJdJzsKdmFyX2R1bXAoJHNhKTsKZWNobyAiPGgzPjIpIGFycmF5IGFzIHN0cmluZyBkZWNvZGVkPC9oMz4iOwokc2FkID0ganNvbl9kZWNvZGUoJHNhKTsKdmFyX2R1bXAoJHNhZCk7CmVjaG8gIjxoMz4zKSBhcnJheSBhcyBzdHJpbmcgZGVjb2RlZCwgdGhlbiBlbmNvZGVkIGFnYWluLiA8c21hbGw+KE5vdGUgaXQncyB0aGUgc2FtZSBhcyB0aGUgb3JpZ2luYWwgc3RyaW5nKTwvc21hbGw+PC9oMz4iOwokc2FkZSA9IGpzb25fZW5jb2RlKCRzYWQpOwp2YXJfZHVtcCgkc2FkZSk7CmVjaG8gIjxoMz40KSBVbnNldCBkZWNvZGVkPC9oMz4iOwoKdW5zZXQoJHNhZFswXSk7CiRzYWQgPSBhcnJheV92YWx1ZXMoJHNhZCk7Cgp2YXJfZHVtcCgkc2FkKTsKZWNobyAiPGgzPjUpIEVuY29kZSB1bnNldCBhcnJheS4gPHNtYWxsPihFeHBlY3RpbmcgaXQgdG8gbG9vayBsaWtlIG9yaWdpbmFsIHN0cmluZyBtaW51cyB0aGUgdW5zZXQgdmFsdWUpPC9zbWFsbD48L2gzPiI7CiRucyA9IGpzb25fZW5jb2RlKCRzYWQpOwp2YXJfZHVtcCgkbnMpOwplY2hvICI8aDM+NikgRGVjb2RlIEVuY29kZWQgdW5zZXQgYXJyYXk8L2gzPiI7CnZhcl9kdW1wKGpzb25fZGVjb2RlKCRucykpOw==
<h3>1) array as string</h3>string(25) "["item1","item2","item3"]"
<h3>2) array as string decoded</h3>array(3) {
[0]=>
string(5) "item1"
[1]=>
string(5) "item2"
[2]=>
string(5) "item3"
}
<h3>3) array as string decoded, then encoded again. <small>(Note it's the same as the original string)</small></h3>string(25) "["item1","item2","item3"]"
<h3>4) Unset decoded</h3>array(2) {
[0]=>
string(5) "item2"
[1]=>
string(5) "item3"
}
<h3>5) Encode unset array. <small>(Expecting it to look like original string minus the unset value)</small></h3>string(17) "["item2","item3"]"
<h3>6) Decode Encoded unset array</h3>array(2) {
[0]=>
string(5) "item2"
[1]=>
string(5) "item3"
}