|
Posted by GamblerZG on 03/27/05 05:04
> Why would you _manually_ edit a serialized array??? One would think you
> would UNSERIALIZE (http://us4.php.net/unserialize) the serialized array
> *before* working with the data.
Well, I guess my initial posting was a bit misleading. I'm writing a
content management system, and that system needs to give its users
ability to create arbitrary data structures. Suppose users should be
able to create hyperlinked menus. Each menu entry must have text, URL
and, possibly, title. There are several ways to achieve such functionality.
1) Write big and ugly interface that does only that – creates menus. Not
very smart, because tomorrow users might need to create nested
categories or some other things.
2) Invent your own syntax for menu programming and write small, but
still ugly procedure that parses that syntax.
3) Invent your own syntax for data structure programming, and write
function that parses it into PHP data structures. Almost a good
solution, but then I would need some way to store, retrieve and edit data.
4) Use something that already exists.
If I can, I would prefer to stick with 4. After all, PHP has
var_export() and eval(). The problem is, var_export() stuffs its output
with junk (extra commas, newlines, spaces), and eval() executes any code.
[Back to original message]
|