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?