Pound key Hash key hashtag in php arrays

0 votes

I am working in some technology stacks (with drupal) and there's this thing with some render arrays. It is getting pound keys infront of the config indexes of the render arrays that are being utilized by the render functions.

The problem is that it has nothing to do with drupal. The code below is independent from php.

   <?php
    $array = array(
      '#title' => 'Social media button settings',
      '#type' => 'fieldset',
      array(
        '#title' => 'Facebook',
        '#type' => 'input',
      )
    );

    foreach($array as $i => $d) {
      // This line could contain ANY!!! key as long as it starts
      // with a pound key.
      if (isset($d['#title'])) {
        var_dump('Index: ' . $i);
        echo 'Data:';
        var_dump($d);
        var_dump('$d["#title"]: ' . $d['#title']);
      }
    }

Output that is returned:

string 'Index: #title' (length=13)

Data:

string 'Social media button settings' (length=28)

string '$d["#title"]: S' (length=15)

string 'Index: #type' (length=12)

Data:

string 'fieldset' (length=8)

string '$d["#title"]: f' (length=15)

string 'Index: 0' (length=8)

Data:

array (size=2)
  '#title' => string 'Facebook' (length=8)
  '#type' => string 'input' (length=5)

string '$d["#title"]: Facebook' (length=22)

Expected result should be:

string 'Index: 0' (length=8)

Data:

array (size=2)
  '#title' => string 'Facebook' (length=8)
  '#type' => string 'input' (length=5)

string '$d["#title"]: Facebook' (length=22)

What is wrong? 

Aug 1 in Others by krishna
• 2,540 points
6 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
0 answers

How can I sort arrays and data in PHP?

These are my primary questions: How do I ...READ MORE

4 days ago in Others by krishna
• 2,540 points
16 views
0 votes
1 answer

Using unserialize in PHP throws the same error repeatedly

I googled 'Node no longer exists', and ...READ MORE

answered Nov 14, 2018 in Others by DataKing99
• 8,240 points
821 views
0 votes
1 answer

Where is the documentation to refer for coinbase api integration of Etherium coin currency in php?

Hey there! Please refer to the following ...READ MORE

answered Jan 25, 2019 in Others by Omkar
• 69,210 points
280 views
0 votes
1 answer
0 votes
1 answer

How to echo WP SEO Yoast synonyms in PHP?

 the meta_key in wp_postmeta table is _yoast_wpseo_keyword ...READ MORE

answered Feb 10 in Others by narikkadan
• 11,280 points
186 views
0 votes
1 answer

How do I get the current date and time in PHP?

The time would go by your server ...READ MORE

answered Feb 16 in Others by Aditya
• 7,300 points
39 views
0 votes
1 answer

How to check if array is multidimensional or not?

Since the 'second dimension' could be just ...READ MORE

answered Nov 5, 2018 in Others by DataKing99
• 8,240 points
3,977 views
0 votes
1 answer

How to store input value into array then localstorage?

Hello @ abhittac, You have create the array everytime the ...READ MORE

answered Jul 24, 2020 in Java-Script by Niroj
• 82,740 points
4,897 views
0 votes
1 answer

Convert a PHP object to an associative array

Start with simply typecasting the line:- $array = ...READ MORE

answered Feb 23 in PHP by Aditya
• 7,300 points
185 views
0 votes
0 answers

php var_dump() vs print_r()

What is the difference between var_dump() and print_r() in terms of ...READ MORE

May 28 in PHP by Kichu
• 19,040 points
22 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP