Substitute to `foreach` for individual array values php -


this current code setup have see prints out each value in table cell.

foreach($ls::getclan() $member) {      echo "<tr><td><label class='label label-danger'>{$member['rank']} | <span>{$member['level']}</span></label></td><td>{$member['username']}</td><td>{$member['donated']}</td><td>{$member['received']} </td></tr>";  } 

i don't know how explain but. uhhhh want use individual value since works best multiple values. e.g:

if ($ls::getclan()['username']) {     // code not work.     // hope guys seeing want cause don't know how explain it.     // can see $ls::getclan()['username'] not work $members['username'] works fine , returns proper value. } 

so code not work. hope guys seeing want cause don't know how explain it. can see $ls::getclan()['username'] not work $members['username'] works fine , returns proper value.

dunno called sorry if question not explain properly/unclear. can tell me how revise though.

also 1 last thing feel free leave me references guys have in mind. gladly read through , learn lot it. :)

note: think right/proper question is: how make $member or work individually , rid of foreach loop altogether.

since php 5.4 can echo $ls::getclan()[0]["username"]; (ref)

example:

class ls {     private static $array = array(array("username" => "mike", "rank" => 10),array("username" => "bob", "rank" => 9));     public static function getclan() {         return self::$array;         } }  $ls = 'ls'; foreach($ls::getclan() $member) {      echo $member["username"] . " " . $member["rank"] . "<br>".php_eol; }  echo $ls::getclan()[0]["username"]; 

mike 10
bob 9
mike


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -