Using arrays : Php array: How can I echo the value of this? on newest questions tagged arrays – Stack Overflow

I am trying to echo a setting on the second level of an array in my wordpress options and having some trouble getting the variable. This code DOES work:

 <?php foreach($area['fields'] as $field): ?>
 <?php if ($field['id'] == 'show_border')
  {echo ' show_border';} ?>
 <?php endforeach; ?>

That simply checks if there is a field that asks if you want to show a border and if there is it echos whatever I want, regardless of what the field is set at for actually showing the border or not.

What I am trying to do is to just echo the value that is set in the field “show_border”.

Any idea how I would do this?

edit

array(11) {
  [0]=>
  array(3) {
    ["name"]=>
    string(10) "# of posts"
    ["id"]=>
    string(5) "posts"
    ["type"]=>
    string(4) "text"
  }
  [1]=>
  array(5) {
    ["name"]=>
    string(13) "posts per row"
    ["id"]=>
    string(13) "posts_per_row"
    ["type"]=>
    string(6) "select"
    ["default"]=>
    int(3)
    ["options"]=>
    array(8) {
      [1]=>
      int(1)
      [2]=>
      int(2)
      [3]=>
      int(3)
      [4]=>
      int(4)
      [5]=>
      int(5)
      [6]=>
      int(6)
      [7]=>
      int(7)
      [8]=>
      int(8)
    }
  }
  [2]=>
  array(5) {
    ["name"]=>
    string(11) "header type"
    ["id"]=>
    string(13) "f_header_type"
    ["type"]=>
    string(6) "select"
    ["default"]=>
    string(2) "h4"
    ["options"]=>
    array(6) {
      ["h1"]=>
      string(2) "h1"
      ["h2"]=>
      string(2) "h2"
      ["h3"]=>
      string(2) "h3"
      ["h4"]=>
      string(2) "h4"
      ["h5"]=>
      string(2) "h5"
      ["h6"]=>
      string(2) "h6"
    }
  }
  [3]=>
  array(5) {
    ["name"]=>
    string(5) "icon?"
    ["id"]=>
    string(9) "show_icon"
    ["type"]=>
    string(5) "radio"
    ["default"]=>
    string(3) "yes"
    ["options"]=>
    array(2) {
      ["yes"]=>
      string(3) "yes"
      ["no"]=>
      string(2) "no"
    }
  }
  [4]=>
  array(5) {
    ["name"]=>
    string(13) "icon location"
    ["id"]=>
    string(13) "icon_location"
    ["type"]=>
    string(6) "select"
    ["default"]=>
    string(4) "left"
    ["options"]=>
    array(3) {
      ["left"]=>
      string(4) "left"
      ["right"]=>
      string(5) "right"
      ["top"]=>
      string(3) "top"
    }
  }
  [5]=>
  array(5) {
    ["name"]=>
    string(10) "show text?"
    ["id"]=>
    string(9) "show_text"
    ["type"]=>
    string(5) "radio"
    ["default"]=>
    string(3) "yes"
    ["options"]=>
    array(2) {
      ["yes"]=>
      string(3) "yes"
      ["no"]=>
      string(2) "no"
    }
  }
  [6]=>
  array(5) {
    ["name"]=>
    string(12) "show border?"
    ["id"]=>
    string(11) "show_border"
    ["type"]=>
    string(5) "radio"
    ["default"]=>
    string(2) "no"
    ["options"]=>
    array(3) {
      ["top"]=>
      string(3) "top"
      ["bot"]=>
      string(3) "bot"
      ["no"]=>
      string(2) "no"
    }
  }
  [7]=>
  array(5) {
    ["name"]=>
    string(8) "category"
    ["id"]=>
    string(8) "category"
    ["type"]=>
    string(6) "select"
    ["multiple"]=>
    bool(true)
    ["options"]=>
    array(2) {
      [4]=>
      string(7) "feature"
      [3]=>
      string(6) "slider"
    }
  }
  [8]=>
  array(4) {
    ["name"]=>
    string(14) "custom classes"
    ["id"]=>
    string(14) "custom_classes"
    ["type"]=>
    string(4) "text"
    ["default"]=>
    string(0) ""
  }
  [9]=>
  array(5) {
    ["name"]=>
    string(10) "read more?"
    ["id"]=>
    string(9) "read_more"
    ["type"]=>
    string(5) "radio"
    ["default"]=>
    string(3) "yes"
    ["options"]=>
    array(2) {
      ["yes"]=>
      string(3) "yes"
      ["no"]=>
      string(2) "no"
    }
  }
  [10]=>
  array(4) {
    ["name"]=>
    string(14) "read more text"
    ["id"]=>
    string(14) "read_more_text"
    ["type"]=>
    string(4) "text"
    ["default"]=>
    string(16) "Continue reading"
  }
}

I am trying to get a value like ["id"]=> “show_border” and echo it’s value.

See Answers


source: http://stackoverflow.com/questions/11756683/php-array-how-can-i-echo-the-value-of-this
Using arrays : using-arrays



online applications demo