2016-10-19 15 views
0

私のデータベースにシリアル化されたフィールドがあります。私はこのフィールドの内容を取得してそれらをシリアル化することができますが、これらの特定の値を取得する方法がわかりません。私は最終的に各項目とデータの値をforeachする必要があります。以下の例では シリアル化されていないデータから値を取得

は、私は次の取得するためにできるようにする必要があります:

メイン画像の交換: BGL_Burhill_People_AndyHiseman_300dpi_Super-サイズ-14.JPG無料: コンプテキスト引用コード:コードテキスト

私は1つの変数としてラベルを必要とし、foreach内で別の値としてラベルを必要とします。これらのラベルと値は可変であるため、ラベルでこのデータを手動で取得することはできません。

array (
    0 => 
    array (
    'mode' => 'builder', 
    'cssclass' => '', 
    'hidelabelinorder' => '', 
    'hidevalueinorder' => '', 
    'element' => 
    array (
     'type' => 'radio', 
     'rules_type' => 
     array (
     'Reprint_0' => 
     array (
      0 => '', 
     ), 
     'Edit Artwork_1' => 
     array (
      0 => '', 
     ), 
    ), 
     '_' => 
     array (
     'price_type' => '', 
    ), 
    ), 
    'name' => '', 
    'value' => 'Edit Artwork', 
    'price' => '', 
    'section' => '58073632e582b5.35893028', 
    'section_label' => '', 
    'percentcurrenttotal' => 0, 
    'currencies' => 
    array (
    ), 
    'price_per_currency' => 
    array (
     'GBP' => '', 
    ), 
    'quantity' => 1, 
    'multiple' => '1', 
    'key' => 'Edit Artwork_1', 
    'use_images' => '', 
    'changes_product_image' => '', 
    'imagesp' => '', 
    'images' => '', 
), 
    1 => 
    array (
    'mode' => 'builder', 
    'cssclass' => '', 
    'hidelabelinorder' => '', 
    'hidevalueinorder' => '', 
    'element' => 
    array (
     'type' => 'radio', 
     'rules_type' => 
     array (
     'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG_0' => 
     array (
      0 => '', 
     ), 
     'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-21.JPG_1' => 
     array (
      0 => '', 
     ), 
     'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-77.JPG_2' => 
     array (
      0 => '', 
     ), 
    ), 
     '_' => 
     array (
     'price_type' => '', 
    ), 
    ), 
    'name' => 'Main Image Replacement', 
    'value' => 'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG', 
    'price' => '', 
    'section' => '58073632e582d2.46631826', 
    'section_label' => 'Main Image Replacement', 
    'percentcurrenttotal' => 0, 
    'currencies' => 
    array (
    ), 
    'price_per_currency' => 
    array (
     'GBP' => '', 
    ), 
    'quantity' => 1, 
    'multiple' => '1', 
    'key' => 'BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14.JPG_0', 
    'use_images' => 'images', 
    'changes_product_image' => '', 
    'imagesp' => '', 
    'images' => 'http://burhill.immaculate.co.uk/wp-content/uploads/2016/10/BGL_Burhill_People_AndyHiseman_300dpi_Super-Size-14-150x150.jpg', 
), 
    2 => 
    array (
    'mode' => 'builder', 
    'cssclass' => 'col-6', 
    'hidelabelinorder' => '', 
    'hidevalueinorder' => '', 
    'element' => 
    array (
     'type' => 'textfield', 
     'rules_type' => 
     array (
     0 => 
     array (
      0 => '', 
     ), 
    ), 
     '_' => 
     array (
     'price_type' => '', 
    ), 
    ), 
    'name' => 'Complimentary', 
    'value' => 'Comp Text', 
    'price' => '', 
    'section' => '58073632e582f4.32183997', 
    'section_label' => 'Complimentary', 
    'percentcurrenttotal' => 0, 
    'currencies' => 
    array (
    ), 
    'price_per_currency' => 
    array (
    ), 
    'quantity' => 1, 
), 
    3 => 
    array (
    'mode' => 'builder', 
    'cssclass' => 'col-6', 
    'hidelabelinorder' => '', 
    'hidevalueinorder' => '', 
    'element' => 
    array (
     'type' => 'textfield', 
     'rules_type' => 
     array (
     0 => 
     array (
      0 => '', 
     ), 
    ), 
     '_' => 
     array (
     'price_type' => '', 
    ), 
    ), 
    'name' => 'Quote Code', 
    'value' => 'Code Text', 
    'price' => '', 
    'section' => '58073632e58317.46363272', 
    'section_label' => 'Quote Code', 
    'percentcurrenttotal' => 0, 
    'currencies' => 
    array (
    ), 
    'price_per_currency' => 
    array (
    ), 
    'quantity' => 1, 
), 
) 
+2

質問している内容が不明です。あなたの配列は乱雑に見え、体系的な取り決めはないようです。それを読みやすくする。 –

+0

ようこそStackOverflowへ。残念ながら、配列には可変データが含まれているため、探しているものが見つかるまで、すべてのデータをループする以外の方法はありません。あなたはどんなコードを投稿していないので、何を試したのか、あなたが直面している問題やエラーは不明です。できるだけ具体的にすることで、より良い回答につながります。 –

答えて

0
foreach($your_array as $key => $value) { 
    $your_value = $value['value']; 
    $your_label = $value['section_label']; 
} 

これは限り私はそこに右のキーを持ってあなたのために働く必要があります。

関連する問題