php5 compatibility: array_fill_keys substitution (if necessary)

pbaggio - November 25, 2008 - 18:02
Project:Graphviz Filter
Version:6.x-1.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

as of "array_fill_keys" help page in php site, there's a contribution by matrebatre stating that this function is the same as "$array = array_combine($keys,array_fill(0,count($keys),$value));"... if it's true, you can achieve php5 compatibility adding the following script (it would be better to place this script in a sort of "heading" place, calling it just one time if possible):

//---- begin script ------------------------------------------
if (!function_exists('array_fill_keys')) {
   function array_fill_keys($keys,$value) {
      return array_combine($keys,array_fill(0,count($keys),$value));
   }
}
//---- end script ------------------------------------------

it immediatly clear that the script above create a new function only if necessary, that is when the original one isn't found.

if you notice that in some cases the equivalence stated is not fully correct, just modify the script above accordingly.

#1

kratib - December 10, 2008 - 23:33
Status:needs review» postponed

I'm planning to revisit the design of Graphviz Filter. I might not need that patch then.

#2

kratib - February 28, 2009 - 18:49
Status:postponed» fixed

Fixed in 6.x-1.3. The module no longer needs that function.

#3

System Message - March 14, 2009 - 18:50
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.