💻 آخرین فرصت یادگیری برنامه‌نویسی با آفر ویژه قبل از افزایش قیمت در ۵ آذر ماه (🎁 به همراه یک هدیه ارزشمند )
۰ ثانیه
۰ دقیقه
۰ ساعت
۴ hamid mostafazadeh
پیمایش در آرایه‌های تو در تو
جامعه پی اچ پی ایجاد شده در ۲۱ بهمن ۱۳۹۹

سلام وقت بخیر در آرایه که ضمیه کردم قسط دارم 

1 -  در قسمت currency اسم‌ها رو بگیرم به طور مثال [USD] [EUR] [AED] و ..

همچنین در همین قسمت مقادیر [price] رو هم میخام بگیرم 

 

2-  در قسمت commodity مقادیر price بگیرم 

چطوری باید اینکار انجام بدیم ؟ 

Array
(
    [currency] => Array
        (
            [USD] => Array
                (
                    [sana] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => USD
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 35
                                            [price] => 233410.00
                                            [slug] => sana_buy_usd
                                            [rate_change] => 2004
                                            [percentage_change] => 0.87
                                            [title] => سامانه سنا دلار خرید
                                            [type_change] => high
                                            [max_rate] => 233410
                                            [min_rate] => 233410
                                        )
                                )
                            [SELL] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => SELL
                                            [unit] => USD
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 38
                                            [price] => 234453.00
                                            [slug] => sana_sell_usd
                                            [rate_change] => 1967
                                            [percentage_change] => 0.85
                                            [title] => سامانه سنا دلار فروش
                                            [type_change] => high
                                            [max_rate] => 234453
                                            [min_rate] => 234453
                                        )
                                )
                        )
                    [free] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => USD
                                            [source] => free
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 47
                                            [price] => 237040.00
                                            [slug] => price_dollar_rl
                                            [rate_change] => 510
                                            [percentage_change] => 0.22
                                            [title] => دلار
                                            [type_change] => low
                                            [max_rate] => 237
                                            [min_rate] => 236
                                        )
                                )
                        )
                )
            [EUR] => Array
                (
                    [sana] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => EUR
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 36
                                            [price] => 278735.00
                                            [slug] => sana_buy_eur
                                            [rate_change] => 1585
                                            [percentage_change] => 0.57
                                            [title] => سامانه سنا یورو خرید
                                            [type_change] => high
                                            [max_rate] => 278735
                                            [min_rate] => 278735
                                        )
                                )
                            [SELL] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => SELL
                                            [unit] => EUR
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 39
                                            [price] => 279782.00
                                            [slug] => sana_sell_eur
                                            [rate_change] => 294
                                            [percentage_change] => 0.11
                                            [title] => سامانه سنا یورو فروش
                                            [type_change] => high
                                            [max_rate] => 279782
                                            [min_rate] => 279782
                                        )
                                )
                        )
                    [free] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => EUR
                                            [source] => free
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 60
                                            [price] => 284420.00
                                            [slug] => price_eur
                                            [rate_change] => 1
                                            [percentage_change] => 0.56
                                            [title] => یورو
                                            [type_change] => low
                                            [max_rate] => 286
                                            [min_rate] => 284
                                        )
                                )
                        )
                )
            [AED] => Array
                (
                    [sana] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => AED
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 37
                                            [price] => 61373.00
                                            [slug] => sana_buy_aed
                                            [rate_change] => 222
                                            [percentage_change] => 0.36
                                            [title] => سامانه سنا درهم خرید
                                            [type_change] => low
                                            [max_rate] => 61373
                                            [min_rate] => 61373
                                        )
                                )
                            [SELL] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => SELL
                                            [unit] => AED
                                            [source] => sana
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 40
                                            [price] => 64547.00
                                            [slug] => sana_sell_aed
                                            [rate_change] => 510
                                            [percentage_change] => 0.79
                                            [title] => سامانه سنا درهم فروش
                                            [type_change] => low
                                            [max_rate] => 64547
                                            [min_rate] => 64547
                                        )
                                )
                        )
                    [free] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => AED
                                            [source] => free
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 61
                                            [price] => 66970.00
                                            [slug] => price_aed
                                            [rate_change] => 20
                                            [percentage_change] => 0.03
                                            [title] => درهم امارات
                                            [type_change] => high
                                            [max_rate] => 67
                                            [min_rate] => 66
                                        )
                                )
                        )
                )
            [GBP] => Array
                (
                    [free] => Array
                        (
                            [BUY] => Array
                                (
                                    [type] => Array
                                        (
                                            [type] => BUY
                                            [unit] => GBP
                                            [source] => free
                                            [pattern] => currency
                                        )
                                    [status] => Array
                                        (
                                            [id] => 62
                                            [price] => 336320.00
                                            [slug] => price_gbp
                                            [rate_change] => 110
                                            [percentage_change] => 0.03
                                            [title] => پوند
                                            [type_change] => high
                                            [max_rate] => 336
                                            [min_rate] => 335
                                        )
                                )
                        )
                )
        )
    [commodity] => Array
        (
            [0] => Array
                (
                    [type] => Array
                        (
                            [type] => SELL
                            [unit] => ons
                            [source] => ons
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 11
                            [price] => 1814.03
                            [slug] => ons
                            [rate_change] => 2.41
                            [percentage_change] => 0.13
                            [title] => انس جهانی طلا
                            [type_change] => high
                            [max_rate] => 1
                            [min_rate] => 1
                        )
                )
            [1] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY-SELL
                            [unit] => MESGHAL
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 12
                            [price] => 26.90
                            [slug] => silver
                            [rate_change] => 0.01
                            [percentage_change] => 0.02
                            [title] => انس جهانی نقره
                            [type_change] => high
                            [max_rate] => 27
                            [min_rate] => 27
                        )
                )
            [2] => Array
                (
                    [type] => Array
                        (
                            [type] => SELL
                            [unit] => platinum
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 13
                            [price] => 1135.70
                            [slug] => platinum
                            [rate_change] => 1.1
                            [percentage_change] => 0.1
                            [title] => انس جهانی پلاتین
                            [type_change] => high
                            [max_rate] => 1
                            [min_rate] => 1
                        )
                )
            [3] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => palladium
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 14
                            [price] => 2344.00
                            [slug] => palladium
                            [rate_change] => 12.25
                            [percentage_change] => 0.53
                            [title] => انس جهانی پالادیوم
                            [type_change] => high
                            [max_rate] => 2
                            [min_rate] => 2
                        )
                )
            [4] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => oil
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 24
                            [price] => 57.08
                            [slug] => oil
                            [rate_change] => 0.07
                            [percentage_change] => 0.12
                            [title] => نفت سبک
                            [type_change] => high
                            [max_rate] => 57
                            [min_rate] => 57
                        )
                )
            [5] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => oil
                            [source] => brent
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 25
                            [price] => 59.56
                            [slug] => oil_brent
                            [rate_change] => 0.07
                            [percentage_change] => 0.12
                            [title] => نفت برنت
                            [type_change] => high
                            [max_rate] => 60
                            [min_rate] => 59
                        )
                )
            [6] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => oil
                            [source] => opec
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 26
                            [price] => 58.25
                            [slug] => oil_opec
                            [rate_change] => 0
                            [percentage_change] => 0
                            [title] => نفت اوپک
                            [type_change] => 
                            [max_rate] => 58
                            [min_rate] => 58
                        )
                )
            [7] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY - SELL
                            [unit] => nim
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 56
                            [price] => 62500000.00
                            [slug] => nim
                            [rate_change] => 600
                            [percentage_change] => 0.96
                            [title] => نیم سکه
                            [type_change] => low
                            [max_rate] => 63
                            [min_rate] => 62
                        )
                )
            [8] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => rob
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 57
                            [price] => 42600000.00
                            [slug] => rob
                            [rate_change] => 300
                            [percentage_change] => 0.71
                            [title] => ربع سکه
                            [type_change] => high
                            [max_rate] => 42
                            [min_rate] => 41
                        )
                )
            [9] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY - SELL
                            [unit] => gerami
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 58
                            [price] => 23100000.00
                            [slug] => gerami
                            [rate_change] => 100
                            [percentage_change] => 0.43
                            [title] => سکه گرمی
                            [type_change] => high
                            [max_rate] => 23
                            [min_rate] => 23
                        )
                )
            [10] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY - SELL
                            [unit] => mesghal
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 63
                            [price] => 47060000.00
                            [slug] => mesghal
                            [rate_change] => 150
                            [percentage_change] => 0.32
                            [title] => مثقال طلا
                            [type_change] => low
                            [max_rate] => 47
                            [min_rate] => 47
                        )
                )
            [11] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY - SELL
                            [unit] => geram18
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 64
                            [price] => 10865000.00
                            [slug] => geram18
                            [rate_change] => 36
                            [percentage_change] => 0.33
                            [title] => گرم طلای 18 عیار
                            [type_change] => low
                            [max_rate] => 10
                            [min_rate] => 10
                        )
                )
            [12] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY - SELL
                            [unit] => geram24
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 65
                            [price] => 14486000.00
                            [slug] => geram24
                            [rate_change] => 49
                            [percentage_change] => 0.34
                            [title] => گرم طلای 24 عیار
                            [type_change] => low
                            [max_rate] => 14
                            [min_rate] => 14
                        )
                )
            [13] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => MESGHAL
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 66
                            [price] => 107519000.00
                            [slug] => sekeb
                            [rate_change] => 0
                            [percentage_change] => 0
                            [title] => سکه بهار آزادی
                            [type_change] => 
                            [max_rate] => 108
                            [min_rate] => 106
                        )
                )
            [14] => Array
                (
                    [type] => Array
                        (
                            [type] => BUY
                            [unit] => MESGHAL
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 67
                            [price] => 109910000.00
                            [slug] => sekee
                            [rate_change] => 1
                            [percentage_change] => 1.66
                            [title] => سکه امامی
                            [type_change] => high
                            [max_rate] => 110
                            [min_rate] => 108
                        )
                )
            [15] => Array
                (
                    [type] => Array
                        (
                            [type] => FLOAT
                            [unit] => bourse
                            [source] => free
                            [pattern] => commodity
                        )
                    [status] => Array
                        (
                            [id] => 68
                            [price] => 1170497.12
                            [slug] => bourse
                            [rate_change] => 35
                            [percentage_change] => 3.1
                            [title] => شاخص بورس
                            [type_change] => high
                            [max_rate] => 1
                            [min_rate] => 1
                        )
                )
        )
)

سلام و احترام

میخواید نام کلیدهای آرایه رو بردارید؟

امیر صالحی ۲۲ بهمن ۱۳۹۹، ۱۴:۳۸

شما با هر دو حالتش بگید 

hamid mostafazadeh ۲۲ بهمن ۱۳۹۹، ۱۵:۱۷

فقط اگه امکان داره یکم سریع‌تر رسیدگی کنین این مورد رو 

hamid mostafazadeh ۲۲ بهمن ۱۳۹۹، ۱۵:۱۸

سلام و احترام

شما میتونید با استفاده از تابع زیر تمامی کلید‌های یه آرایه رو بگیرید

$array = array(0 => 100, "color" => "red");
print_r(array_keys($array));

Array
(
    [0] => 0
    [1] => color
)

و با استفاده از تابع زیر میتونید مقادیر یه کلید که درچندین جا تکرار شدند رو دریافت کنید:

$records = array(
    array(
        'id' => 2135,
        'first_name' => 'John',
        'last_name' => 'Doe',
    ),
    array(
        'id' => 3245,
        'first_name' => 'Sally',
        'last_name' => 'Smith',
    ),
    array(
        'id' => 5342,
        'first_name' => 'Jane',
        'last_name' => 'Jones',
    ),
    array(
        'id' => 5623,
        'first_name' => 'Peter',
        'last_name' => 'Doe',
    )
);
$first_names = array_column($records, 'first_name');
print_r($first_names);

Array
(
    [0] => John
    [1] => Sally
    [2] => Jane
    [3] => Peter
)

 

 

 

 

امیر صالحی ۲۲ بهمن ۱۳۹۹، ۲۱:۰۶