久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

多維數(shù)組 - 如何從子數(shù)組中獲取特定值

Multidimensional array - how to get specific values from sub-array(多維數(shù)組 - 如何從子數(shù)組中獲取特定值)
本文介紹了多維數(shù)組 - 如何從子數(shù)組中獲取特定值的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有以下數(shù)組結(jié)構(gòu):

<前>大批([0] => 數(shù)組([product_option_id] => 236[option_id] => 14[名稱] => Masura S[類型] => 選擇[option_value] => 數(shù)組([0] => 數(shù)組([product_option_value_id] => 33[option_value_id] => 53[名稱] => 阿爾伯[價(jià)格] =>[價(jià)格前綴] => +)[1] => 數(shù)組([product_option_value_id] => 35[option_value_id] => 55[名稱] => 羅蘇[價(jià)格] =>[價(jià)格前綴] => +))[必需] => 0)[1] => 數(shù)組([product_option_id] => 237[option_id] => 15[名稱] => Masura M[類型] => 選擇[option_value] => 數(shù)組([0] => 數(shù)組([product_option_value_id] => 34[option_value_id] => 58[名稱] => 羅蘇[價(jià)格] =>[價(jià)格前綴] => +))[必需] => 0))

我發(fā)現(xiàn)自己在試圖顯示此數(shù)組中的所有 [name] 值時(shí)迷失了方向.

我想要做的是根據(jù)第一級[name](如[name] => Masura S)用下拉選擇填充表單然后第二個(gè)下拉選擇帶有第二級 [name](如 [name] => Alb).

如果您有任何指點(diǎn),我將不勝感激...

解決方案

您可以通過以下方式填充第一個(gè)選擇:

<?phpfor ( $i=0; $i <$c; $i++){$c2=count($array[$i]);對于 ($j=0;$j<$c2;$j++){?><option><?php echo $array[$i][$j]['name'];?></option><?php }} ?></選擇>

I have the following array structure:

Array
(
    [0] => Array
        (
            [product_option_id] => 236
            [option_id] => 14
            [name] => Masura S
            [type] => select
            [option_value] => Array
                (
                    [0] => Array
                        (
                            [product_option_value_id] => 33
                            [option_value_id] => 53
                            [name] => Alb
                            [price] => 
                            [price_prefix] => +
                        )

                    [1] => Array
                        (
                            [product_option_value_id] => 35
                            [option_value_id] => 55
                            [name] => Rosu
                            [price] => 
                            [price_prefix] => +
                        )

                )

            [required] => 0
        )

    [1] => Array
        (
            [product_option_id] => 237
            [option_id] => 15
            [name] => Masura M
            [type] => select
            [option_value] => Array
                (
                    [0] => Array
                        (
                            [product_option_value_id] => 34
                            [option_value_id] => 58
                            [name] => Rosu
                            [price] => 
                            [price_prefix] => +
                        )

                )

            [required] => 0
        )
)

I find myself lost in trying to display all the [name] values from this array.

What I am trying to do is to populate a form with dropdown selects based on the first level [name] (like [name] => Masura S) and then a second dropdown select with the second level [name] (like [name] => Alb).

I would appreciate it if you have any pointers...

解決方案

You can populate the first select this way:

<select>

    <?php $c=count($array);
    for ( $i=0; $i < $c; $i++)
    { ?>
        <option><?php echo $array[$i]['name'];?></option>
    <?php } ?>   

</select>

2nd select:

<select>

    <?php 
    for ( $i=0; $i < $c; $i++)
    { 
        $c2=count($array[$i]); 
        for ($j=0;$j<$c2;$j++){ 
    ?>
        <option><?php echo $array[$i][$j]['name'];?></option>
    <?php }} ?>

</select>

這篇關(guān)于多維數(shù)組 - 如何從子數(shù)組中獲取特定值的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個(gè)表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設(shè)置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數(shù)組自動(dòng)填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產(chǎn)生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: 日本精品视频 | 求av网址 | 午夜www | 成人免费看片98欧美 | 激情久久久 | 黄色草逼视频 | 亚洲一区二区三区在线播放 | 国产视频网| 欧美日韩高清 | 91调教打屁股xxxx网站 | 欧美色婷婷 | 欧美一级黄色录像 | 一区二区三区在线观看视频 | 九九国产精品视频 | 在线播放a | 国产精品久久久久久久久久久久久 | 亚洲黄色天堂 | 久久久精 | 成av人片一区二区三区久久 | 男人天堂av网| 中文在线免费观看 | 综合色婷婷| 99久热| 国产成人精品免费 | 99热在线免费观看 | 久在线视频 | 午夜精品视频在线观看 | 久久精品一二三 | 免费三级网站 | 三上悠亚激情av一区二区三区 | 一区二区三区四区视频 | 一级片在线免费观看 | 国产精品福利视频 | 88av视频 | 男女操操操 | 黑人巨大精品欧美一区二区 | 精品视频在线观看 | 亚洲一区精品视频 | 国产主播精品 | 一区二区视频网站 | 国产成人午夜精品 |