Solved

Multi dimension array

Posted on 2011-09-19
2
461 Views
Last Modified: 2012-05-12
I have get value of Multi dimension array. how can get is. My array is mentions below. please refer that and please give me a reply.

I need a value of 8,9 so how can get a both value using PHP?


Array
(
    [field_add_title] => Array
        (
            [#theme] => field
            [#weight] => 0
            [#title] => Title
            [#access] => 1
            [#label_display] => above
            [#view_mode] => full
            [#language] => und
            [#field_name] => field_add_title
            [#field_type] => text
            [#field_translatable] => 1
            [#entity_type] => field_collection_item
            [#bundle] => field_adress
            [#object] => FieldCollectionItemEntity Object
                (
                    [fieldInfo:protected] =>
                    [hostEntity:protected] => stdClass Object
                        (
                            [vid] => 84
                            [uid] => 1
                            [title] => Court Locations
                            [log] =>
                            [status] => 1
                            [comment] => 1
                            [promote] => 0
                            [sticky] => 0
                            [ds_switch] =>
                            [nid] => 83
                            [type] => address
                            [language] => und
                            [created] => 1315574149
                            [changed] => 1316232612
                            [tnid] => 0
                            [translate] => 0
                            [revision_timestamp] => 1316232612
                            [revision_uid] => 1
                            [body] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] =>
Content Display Here...

                                                    [summary] =>
                                                    [format] => full_html
                                                    [safe_value] =>


Content Display Here...
 


                                                    [safe_summary] =>
                                                )

                                        )

                                )

                            [field_adress] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] => 8
                                                )

                                            [1] => Array
                                                (
                                                    [value] => 9
                                                )

                                        )


                                )
0
Comment
Question by:naeemsabasara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 14

Expert Comment

by:Scott Madeira
ID: 36560827
Perhaps something like:

$variable['field_add_title']['#object']->hostEntity->field_address[und][0]['value']

$variable['field_add_title']['#object']->hostEntity->field_address[und][1]['value']
0
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 250 total points
ID: 36592642
Suggest you get this book and give yourself a little while to study.  If you are going to tackle problems like this you need to have a sturdy foundation of understanding PHP and MySQL.  This little book will be very helpful.
http://www.sitepoint.com/books/phpmysql4/

I am not sure I understand your question but I will try.  Let's look at this part, taking misspelled English words into account.

                           [field_adress] => Array
                                (
                                    [und] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [value] => 8
                                                )

                                            [1] => Array
                                                (
                                                    [value] => 9
                                                )

                                        )

                                )


What that is telling us is that you have some kind of array or object that contains a variable named field_adress.  Inside that variable is another array named und.  Und is a numerically indexed array.  Inside und there are two associative arrays with keys named value pointing to the 8 and the 9.  It might be hard to find a more confusing data structure.

Since we do not know for sure what the name of the highest-level array or object might be. I will assume that it is an array named $arr.

This would be the way to get the value elements.

foreach ($arr['field_adress']['und'] as $thing)
{
    var_dump($thing['value']);
}
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question