多维阵列值的问题每次不赞成

发布于 2025-02-03 00:48:52 字数 22123 浏览 2 评论 0原文

我有未进行的阵列,但我很渴望从数组中获得值。下面我的数组:

array(5) {
  [0]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(63) " Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(20) " 3.3 lbs. (1.5 kg)  "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(15) "OSHA Standards:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "  1926.502"
        }
      }
    }
  }
  [1]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(65) " Clear resin housing
        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(74) " 1.9 lbs. (.9 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(16) "OSHA Standards: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(9) " 1926.502"
        }
      }
    }
  }
  [2]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(10) "Materials:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(64) "  Clear resin housing
        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(75) " 3.3 lbs. (1.5 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "130-310 lbs. (59-141 kg) 

        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(15) "OSHA Standards:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "  1926.502"
        }
      }
    }
  }
  [3]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(67) " Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(75) " 2.8 lbs. (1.3 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "OSHA Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(8) "1926.502"
        }
      }
    }
  }
  [4]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(76) "Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(17) "3.3 lbs. (1.5 kg)"
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "7' (2.1 m)"
        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(22) "ANSI Weight Capacity: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(22) "OSHA Weight Capacity: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "Up to 420 lbs. (191 kg)  "
        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(15) "Z359.14
        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(17) "OSHA Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(8) "1926.502"
        }
      }
    }
  }
}

我试图通过foreach循环代码获取值:

$last_ext = '';
foreach ($arr['body'] as $items ){
$last_ext .= trim($items[0]['c']) . ' ' . trim($items[1]['c']); $last_ext .= "\r\n";}

运行代码后,只有第一个数组值的数据出现在输出中。其他数组值的数据不会出现。这样的代码返回:

Attachment Points: 1 dorsal D-ring, 2 side positioning D-rings
Weight: 5.8 lbs. (2.6 kg)
ANSI Weight Capacity: 130-310 lbs. (59-141 kg)
OSHA Weight Capacity: Up to 420 lbs. (191 kg)
ANSI Standards: Z359.11-2021
OSHA Standards: 1926.502, 1910.140

我需要什么?

示例中的数据仅来自第一个数组,正如我所说的。我无法从第二或第三个数组中获取数据。

更多解释

“身体”阵列内有1个数组。那个阵列有7个 大批。这7个阵列中有“身体”阵列。我需要拉数据 这些阵列中的0-> c和1-> c。

JSON DECODE VAR_EXPORT:

array (
  0 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel'
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight:'
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg)'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength:'
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity: '
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards:'
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
  1 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel'
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight: '
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg) ea / 20 lbs (9.1 kg) per 25'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength:'
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity:'
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards: '
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
  2 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel anchor
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight:'
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg)'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength: '
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity:'
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards: '
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
)

这是JSON_ENCODE

][
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: " 3.3 lbs. (1.5 kg)  "
                }
            ]
            [
                {
c: "\\nLength: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:"
                }
                {
c: "  1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "\\nWeight: "
                }
                {
c: " 1.9 lbs. (.9 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards: "
                }
                {
c: " 1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials:"
                }
                {
c: "  Clear resin housing
                }
            ]
            [
                {
c: "\\nWeight: "
                }
                {
c: " 3.3 lbs. (1.5 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) \\n"
                }
            ]
            [
                {
c: "OSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:"
                }
                {
c: "  1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: " 2.8 lbs. (1.3 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:  "
                }
                {
c: "1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: "Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: "3.3 lbs. (1.5 kg)"
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: "7\' (2.1 m)"
                }
            ]
            [
                {
c: "ANSI Weight Capacity: "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "OSHA Weight Capacity: "
                }
                {
c: "Up to 420 lbs. (191 kg)  "
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:  "
                }
                {
c: "1926.502"
                }
            ]
        ]
    }
][

更新

我正在尝试在下面获取值代码,但我如何在数组中或其他其他方式合并此值

$spec1 = $ultray[0];
$spec2 = $ultray[1];
$spec3 = $ultray[2];
$spec4 = $ultray[3];
$spec5 = $ultray[4];
$spec6 = $ultray[5];
$spec7 = $ultray[6];
$spec8 = $ultray[7];
$spec9 = $ultray[8];

I got unserialized array but i am strugling to get values from array. My array below:

array(5) {
  [0]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(63) " Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(20) " 3.3 lbs. (1.5 kg)  "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(15) "OSHA Standards:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "  1926.502"
        }
      }
    }
  }
  [1]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(65) " Clear resin housing
        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(74) " 1.9 lbs. (.9 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(16) "OSHA Standards: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(9) " 1926.502"
        }
      }
    }
  }
  [2]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(10) "Materials:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(64) "  Clear resin housing
        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(9) "
Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(75) " 3.3 lbs. (1.5 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "130-310 lbs. (59-141 kg) 

        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(15) "OSHA Standards:"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "  1926.502"
        }
      }
    }
  }
  [3]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(67) " Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(75) " 2.8 lbs. (1.3 kg)                                                         "
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(12) " 7' (2.1 m)

        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(23) "ANSI Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(24) "
OSHA Weight Capacity:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(26) "Up to 420 lbs. (191 kg)  

        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(16) "Z359.14

        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(17) "OSHA Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(8) "1926.502"
        }
      }
    }
  }
  [4]=>
  array(3) {
    ["header"]=>
    bool(false)
    ["caption"]=>
    bool(false)
    ["body"]=>
    array(8) {
      [0]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Class A SRL"
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(0) ""
        }
      }
      [1]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(11) "Materials: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(76) "Clear resin housing

        }
      }
      [2]=>
      array(2) {
        [0]=>
        array(1) {
          [c"]=>
          string(8) "Weight: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(17) "3.3 lbs. (1.5 kg)"
        }
      }
      [3]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(8) "Length: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(10) "7' (2.1 m)"
        }
      }
      [4]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(22) "ANSI Weight Capacity: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "130-310 lbs. (59-141 kg) "
        }
      }
      [5]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(22) "OSHA Weight Capacity: "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(25) "Up to 420 lbs. (191 kg)  "
        }
      }
      [6]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(17) "ANSI Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(15) "Z359.14
        }
      }
      [7]=>
      array(2) {
        [0]=>
        array(1) {
          ["c"]=>
          string(17) "OSHA Standards:  "
        }
        [1]=>
        array(1) {
          ["c"]=>
          string(8) "1926.502"
        }
      }
    }
  }
}

I am trying to get values with foreach loops code :

$last_ext = '';
foreach ($arr['body'] as $items ){
$last_ext .= trim($items[0]['c']) . ' ' . trim($items[1]['c']); $last_ext .= "\r\n";}

After running the code, only the data of the first array values comes in the output. The data of other array values is not coming. Code returns like this :

Attachment Points: 1 dorsal D-ring, 2 side positioning D-rings
Weight: 5.8 lbs. (2.6 kg)
ANSI Weight Capacity: 130-310 lbs. (59-141 kg)
OSHA Weight Capacity: Up to 420 lbs. (191 kg)
ANSI Standards: Z359.11-2021
OSHA Standards: 1926.502, 1910.140

What i need ?

The data in the example comes only from the first array, as I said. I couldn't get the data from the second or third arrays.

More Explanition

There is 1 array inside the 'body' array. There are 7 arrays in that 1
array. There are 'body' arrays in those 7 arrays. I need to pull data
0->c and 1->c in these arrays.

JSON Decode var_export :

array (
  0 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel'
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight:'
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg)'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength:'
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity: '
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards:'
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
  1 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel'
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight: '
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg) ea / 20 lbs (9.1 kg) per 25'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength:'
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity:'
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards: '
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
  2 => 
  array (
    'header' => false
    'caption' => false
    'body' => 
    array (
      0 => 
      array (
        0 => 
        array (
          'c' => 'Materials:'
        )
        1 => 
        array (
          'c' => 'Zinc plated steel anchor
        )
      )
      1 => 
      array (
        0 => 
        array (
          'c' => 'Weight:'
        )
        1 => 
        array (
          'c' => '0.8 lbs. (0.4 kg)'
        )
      )
      2 => 
      array (
        0 => 
        array (
          'c' => 'Length:'
        )
        1 => 
        array (
          'c' => '16.25" (7.4 mm)'
        )
      )
      3 => 
      array (
        0 => 
        array (
          'c' => 'Minimum Breaking Strength: '
        )
        1 => 
        array (
          'c' => '3
        )
      )
      4 => 
      array (
        0 => 
        array (
          'c' => 'Weight Capacity:'
        )
        1 => 
        array (
          'c' => '130-310 lbs. (59-141 kg)'
        )
      )
      5 => 
      array (
        0 => 
        array (
          'c' => 'OSHA Standards: '
        )
        1 => 
        array (
          'c' => '1926.502
        )
      )
    )
  )
)

Here is json_encode

][
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: " 3.3 lbs. (1.5 kg)  "
                }
            ]
            [
                {
c: "\\nLength: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:"
                }
                {
c: "  1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "\\nWeight: "
                }
                {
c: " 1.9 lbs. (.9 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards: "
                }
                {
c: " 1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials:"
                }
                {
c: "  Clear resin housing
                }
            ]
            [
                {
c: "\\nWeight: "
                }
                {
c: " 3.3 lbs. (1.5 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) \\n"
                }
            ]
            [
                {
c: "OSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:"
                }
                {
c: "  1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: " Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: " 2.8 lbs. (1.3 kg)                                                         "
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: " 7\' (2.1 m)\\n"
                }
            ]
            [
                {
c: "ANSI Weight Capacity:  "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "\\nOSHA Weight Capacity:  "
                }
                {
c: "Up to 420 lbs. (191 kg)  \\n"
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:  "
                }
                {
c: "1926.502"
                }
            ]
        ]
    }
    {
header: false
caption: false
body: [
            [
                {
c: "Class A SRL"
                }
                {
c: ""
                }
            ]
            [
                {
c: "Materials: "
                }
                {
c: "Clear resin housing
                }
            ]
            [
                {
c: "Weight: "
                }
                {
c: "3.3 lbs. (1.5 kg)"
                }
            ]
            [
                {
c: "Length: "
                }
                {
c: "7\' (2.1 m)"
                }
            ]
            [
                {
c: "ANSI Weight Capacity: "
                }
                {
c: "130-310 lbs. (59-141 kg) "
                }
            ]
            [
                {
c: "OSHA Weight Capacity: "
                }
                {
c: "Up to 420 lbs. (191 kg)  "
                }
            ]
            [
                {
c: "ANSI Standards:  "
                }
                {
c: "Z359.14
                }
            ]
            [
                {
c: "OSHA Standards:  "
                }
                {
c: "1926.502"
                }
            ]
        ]
    }
][

UPDATE

I am trying got get values code below and it gets values but how i merge this values in array or someting else

$spec1 = $ultray[0];
$spec2 = $ultray[1];
$spec3 = $ultray[2];
$spec4 = $ultray[3];
$spec5 = $ultray[4];
$spec6 = $ultray[5];
$spec7 = $ultray[6];
$spec8 = $ultray[7];
$spec9 = $ultray[8];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南烟 2025-02-10 00:48:52

你是说:

$last_ext = '';
foreach ($arr['body'] as $items ){
    foreach ($items as $i){
        $last_ext .= trim($i['c']) . ' ';
    }
    $last_ext = trim($last_ext) . "\r\n";
}

Do you mean like:

$last_ext = '';
foreach ($arr['body'] as $items ){
    foreach ($items as $i){
        $last_ext .= trim($i['c']) . ' ';
    }
    $last_ext = trim($last_ext) . "\r\n";
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文