Equivalent PROCV in PHP -


i have table:

class   | name  |  --------+-------+ mage    | merlim| warrior | gatz  | rogue   | zoro  | 

how can name of given class? it's procv function of excel.

in php code:

//$table result returned call db shown above  $classes_required = array("mage","warrior","rogue"); foreach($classes_required $class){     $$class = procv_equivalent($table, $class); } 

result of var_export($table);

 array (       0 => array ( 0 => 'class', 1 => 'name'),       1 => array ( 0 => 'mage', 1 => 'merlim'),       2 => array ( 0 => 'warrior', 1 => 'gatz'),        3 => array ( 0 => 'rogue', 1 => 'zoro'),    ) 

you can build associative array maps class name:

$classname = array(); ($i = 1; $i < count($table); $i++) {   $row = $table[$i];   $classname[$row[0]] = $row[1]; }  foreach ($classes_required $class) {   $name = $classname[$class]; } 

Comments

Popular posts from this blog

symfony - TEST environment only: The database schema is not in sync with the current mapping file -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -