Mohamed Omar
Mohamed Omar

Reputation: 11

How to retrieve an element from this PHP array?

So basically I have this array stored in SQL and I'm trying to retrieve the first element from it using PHP

I'm not sure if this is an associative or multidimensional array

a:3:{i:0;s:11:"Downpayment";i:1;s:28:"Variable 1 ";i:2;s:28:"Variable 2";}

How do I extract elements from this array ?

Upvotes: 0

Views: 50

Answers (2)

genesst
genesst

Reputation: 1431

This is a PHP representation of serialized data. Use unserialize() on it.

Upvotes: 2

Artem Ilchenko
Artem Ilchenko

Reputation: 1035

If you not sure in this array you can use current() function or foreach to get first element of this array

For set inner pointer on first element use reset()

Upvotes: 0

Related Questions