Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #14969
| From | Jerry Stuckle <jstucklex@attglobal.net> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: 4 dimensional associative array access |
| Date | 2015-02-23 15:44 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <mcg3da$tbu$1@dont-email.me> (permalink) |
| References | <f6d75dde-ec33-4c8e-8d77-b370152a72bd@googlegroups.com> <0a046a55-b4d4-453d-8ae1-a41e1c1eaf7a@googlegroups.com> |
On 2/23/2015 1:26 PM, Adnan Shiekh wrote:
> Sorry to all i'm ask question in wrong way basically my $result return some thing else but for long i am not show here.. i'm show the output after var_dump($result) is:
>
> array(2) { ["response"]=> array(2) { ["success"]=> bool(true) ["result"]=> array(34) { [0]=> array(15) { ["id"]=> string(7) "1965684" ["device_id"]=> string(4) "6386" ["Email"]=> string(28) "Hello sir how do you feel..!" ["status"]=> string(7) "pending" ["send_at"]=> int(1424675520) ["queued_at"]=> int(0) ["sent_at"]=> int(0) ["delivered_at"]=> int(0) ["canceled_at"]=> int(0) ["failed_at"]=> int(0) ["received_at"]=> int(0) ["error"]=> string(0) "" ["created_at"]=> int(1424675520) ["contact"]=> array(3) { ["id"]=> string(6) "348244" ["name"]=> string(9) "My Number" ["number"]=> string(11) "56486464624" } } [1]=> array(15)
>
>
> i'm try to ask how to retrieve some particular fields in this type of array.. sorry for wrong type question but i'm also thank full to reply my answer i hope you help me and guide me thanks.....
>
OK, this helps. You don't show the entire contents of $result (it is
quite large), but we can get a start.
Within your variable are nested arrays (multidimensional); some are
indexed and some are associative. That is:
The first array is an associative array and the first element of the
array is 'response', so it would be accessed as
$result['response']
This is an array with two associative members, 'success' and 'result'.
They would be accessed as
$result['response']['success'] and
$result['response']['result']
respectively.
The 'success' member is simply a boolean value, so the above accesses it
directly.
The 'result' member has as its contents an indexed array with 34
members. These would be accessed as
$result['response']['result'][0]
$result['response']['result'][1]
$result['response']['result'][2]
and so on, through
$result['response']['result'][33]
Each of these arrays is an associative array. The first has 15 members,
'id', 'device_id', etc., through 'contact', so they would be addressed as
$result['response']['result'][0]['id']
$result['response']['result'][0]['device_id']
...
$result['response']['result'][0]['contact']
The first 14 elements are simple values, and are accessed by the above.
The 'contact' element is an associative array with members 'id', 'name'
and 'number'. They would be accessed as
$result['response']['result'][0]['contact']['id']
$result['response']['result'][0]['contact']['name']
$result['response']['result'][0]['contact']['number']
This is all the farther I could take it because that's the end of the data.
I hope this helps. It's all a matter of breaking down the output of
var_dump() or print_r() (it helps if you have it formatted) and going
down the arrays one step at a time.
--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
4 dimensional associative array access Adnan Shiekh <adnanshahi123@gmail.com> - 2015-02-23 00:09 -0800
Re: 4 dimensional associative array access Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-23 09:48 -0500
Re: 4 dimensional associative array access Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-23 15:52 +0100
Re: 4 dimensional associative array access Adnan Shiekh <adnanshahi123@gmail.com> - 2015-02-23 10:26 -0800
Re: 4 dimensional associative array access Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-23 15:44 -0500
Re: 4 dimensional associative array access Adnan Shiekh <adnanshahi123@gmail.com> - 2015-02-23 10:39 -0800
Re: 4 dimensional associative array access Adnan Shiekh <adnanshahi123@gmail.com> - 2015-02-23 13:31 -0800
Re: 4 dimensional associative array access Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-23 22:39 +0000
Re: 4 dimensional associative array access Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-24 00:13 +0000
Re: 4 dimensional associative array access Denis McMahon <denismfmcmahon@gmail.com> - 2015-02-24 01:49 +0000
Re: 4 dimensional associative array access Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-23 20:56 -0500
Re: 4 dimensional associative array access Adnan Shiekh <adnanshahi123@gmail.com> - 2015-02-23 23:07 -0800
Re: 4 dimensional associative array access Jerry Stuckle <jstucklex@attglobal.net> - 2015-02-24 07:47 -0500
csiph-web