i insert in database values (array) with use function serialize(), how can echo they with unserialize() in tag <ul><li>...?
i have in database this: a:6:{i:0;s:15:"Coffee";i:1;s:14:"Satellite";i:2;s:11:"Game Notes";i:3;s:14:"Internet";i:4;s:10:"Pool";i:5;s:0:"";}
LIKE:
- Coffee
- Game Notes
- Internet
- Pool
You need to use
unserialize(), as you said, with aforeach()loop, like this:This will echo a list containing
valuebecauseforeach()iterates through theunserialize()d array, as you have specified in your question.The
$key => $partis the icing on the cake forforeach(); if you want the get the array key, simply reference$key. If you want the data for that key, use$val.If you want to echo just one element (your example is
Internet), just don’t use a loop and reference it by key (integer):This
echos the third element in the array on it’s own.