I am trying to create an associative array with alphabets as keys and 1 to 26 as values which I need to use to find the offset of alphabet from 1. So array[‘a’] would give me 1 and array[‘c’] would give me 3. Is there a way to declare such an array without typing in all characters 1 by 1 as in
array(‘a’ => 1, ‘b’ =>2, ‘c’=>3 …. and so on
Or is there another way to get offset for alphabet from 1 to 26
You could do this using
array_combine()andrange():