Page 1 of 1

How to access array contents and serialize data

Posted: Sat Sep 28, 2013 12:59 am
by new_member
Hi,

I want to access the contents of this particular array :
Array
(
[0] => Array

(
[test] => test1
[test2] => test2

)

[1] => Array

(
[test] => test1
[test2] => test2

)

)

I want to use foreach loop but i dont know how to access the elemens of this kind of array. I have tried a lot but couldnt find any way

Moreover i want to serialze the array

[values] => Array
(
[0] => Array
(
[val1] => val1
[val2] => val2

)

)

i have serialized it using php function serialize on values array but it returns null. Can anyone tell how to do this??

Re: How to access array contents and serialize data

Posted: Sat Sep 28, 2013 7:00 am
by Celauran

Code: Select all

foreach ($array as $item) {
    echo $item['test'];
    echo $item['test2'];
}

Code: Select all

$foo = serialize($bar)
What code are you using?

Re: How to access array contents and serialize data

Posted: Sat Sep 28, 2013 8:38 am
by new_member
i am using simply

serialize($this->values)

printing $this->values gives correct array values but serializing giving empty results

Re: How to access array contents and serialize data

Posted: Sat Sep 28, 2013 9:56 am
by AbraCadaver
Why are you serializing it?