]> git.mxchange.org Git - friendica.git/blobdiff - library/phpsec/PHP/Compat/Function/array_fill.php
bug #96 move libraries to library - better alignment of like rotator
[friendica.git] / library / phpsec / PHP / Compat / Function / array_fill.php
diff --git a/library/phpsec/PHP/Compat/Function/array_fill.php b/library/phpsec/PHP/Compat/Function/array_fill.php
new file mode 100644 (file)
index 0000000..e02bfa1
--- /dev/null
@@ -0,0 +1,43 @@
+<?php\r
+// $Id: array_fill.php,v 1.1 2007/07/02 04:19:55 terrafrost Exp $\r
+\r
+\r
+/**\r
+ * Replace array_fill()\r
+ *\r
+ * @category    PHP\r
+ * @package     PHP_Compat\r
+ * @license     LGPL - http://www.gnu.org/licenses/lgpl.html\r
+ * @copyright   2004-2007 Aidan Lister <aidan@php.net>, Arpad Ray <arpad@php.net>\r
+ * @link        http://php.net/function.array_fill\r
+ * @author      Jim Wigginton <terrafrost@php.net>\r
+ * @version     $Revision: 1.1 $\r
+ * @since       PHP 4.2.0\r
+ */\r
+function php_compat_array_fill($start_index, $num, $value)\r
+{\r
+    if ($num <= 0) {\r
+        user_error('array_fill(): Number of elements must be positive', E_USER_WARNING);\r
+\r
+        return false;\r
+    }\r
+\r
+    $temp = array();\r
+\r
+    $end_index = $start_index + $num;\r
+    for ($i = (int) $start_index; $i < $end_index; $i++) {\r
+        $temp[$i] = $value;\r
+    }\r
+\r
+    return $temp;\r
+}\r
+\r
+// Define\r
+if (!function_exists('array_fill')) {\r
+    function array_fill($start_index, $num, $value)\r
+    {\r
+        return php_compat_array_fill($start_index, $num, $value);\r
+    }\r
+}\r
+\r
+?>
\ No newline at end of file