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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -