fork download
  1. <?php
  2.  
  3. $arrPref = array(
  4. 1 => '北海道'
  5. , 2 => '青森'
  6. );
  7.  
  8. $arrSetting = array(
  9. 1 => array(
  10. 'eq' => array(2, 4, 5)
  11. , 'url' => 'http://h...content-available-to-author-only...u.com/'
  12. )
  13. , 2 => array(
  14. 'eq' => array(2, 4, 5)
  15. , 'url' => 'http://a...content-available-to-author-only...i.com/'
  16. )
  17. );
  18.  
  19. $res = $arrSetting[array_search('北海道', $arrPref)];
  20. print_r($res);
  21.  
  22. $res = $arrSetting[array_search('東海道', $arrPref)];
  23. print_r($res);
  24.  
  25.  
  26.  
  27. $pref = array(
  28. "北海道" => array ("url1", array(1,2) /* array() */),
  29. "青森" => array ("url2", array(2,3) /* array() */),
  30. );
  31.  
  32. list($url, $eq) = $pref["北海道"];
  33. print_r(compact("url", "eq"));
  34.  
  35. list($url, $eq) = $pref["東海道"];
  36. print_r(compact("url", "eq"));
  37.  
Success #stdin #stdout #stderr 0.02s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [eq] => Array
        (
            [0] => 2
            [1] => 4
            [2] => 5
        )

    [url] => http://h...content-available-to-author-only...u.com/
)
Array
(
    [url] => url1
    [eq] => Array
        (
            [0] => 1
            [1] => 2
        )

)
Array
(
    [url] => 
    [eq] => 
)
stderr
PHP Notice:  Undefined offset: 0 in /home/v0hDbk/prog.php on line 22
PHP Notice:  Undefined index: 東海道 in /home/v0hDbk/prog.php on line 35