I’m trying to use redis with multidimensional array by using HMSET.
My array looks like this.
Array
(
[t] => Hello
[a] => This
[c] => key
[b] => 23
[data] => Array
(
[1] => some value
[more] => value
)
)
Is there any way I can store data in this format in the redis using predis library.
Yes, Redis is able to store strings and PHP is able to serialize (multidimensional) array to strings.
The
serializefunction in the example can be used for that exact job, but is only exemplary, you can use any serialization method that serializes your data into a (binary) string.For example you can make use of JSON (
json_encode), XML or in some cases justimplodemight be fitting.