PHP - Use value from array outside of the array -


i have array contains multiple other arrays. these arrays have value called [note] references variable called $thenote located above/outside array. variable holds simple template few spans.

$thenote = '<span class="icon"></span><span>hello name $thename</span>'; 

i have array called client_infos contains multiple arrays inside like

  'client_infos' => array (        array (             'name' => 'john smith',             'note' => $thenote,             'prepend' => '',             'append' => '',             'formatting' => 'html',         ),         array (             'name' => 'mary smith',             'note' => $thenote,             'prepend' => '',             'append' => '',             'formatting' => 'html',         ),     ); 

there unknown number of names eventually. need able in template, call $thenote in loop or , following outputted...

<span class="icon"></span><span>hello name john smith</span> 

as can see, [note] info in array uses $thenote varible, outputs block of code variable inside called $thename. not know how [name] info.. $thename variable.

basically how get. $thename inside $thenote = current array [name] value.

the reason of can update "the note" code once, without having in child arrays.

i hope being clear enough, ideas?

it may better use class here:

class client {     private $name;     private $prepend;     private $append;     private $formatting;      // place constructor here      // create getter , setter properties     public function getnote() {         return '<span class="icon"></span><span>hello name ' . $this->name . '</span>'     } } 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -