<?php /*********************************************
* Script: Multi-Dimentional Array Handler (marray) Functions | Author: Colin Jermain | Contact: http://phpknowhow.com/contact.php | Date: January 25th, 2008 | Version: 1.0
* License:
* Copyright (C) 2008 Colin Jermain
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************/
function marray_loc($loc) {try {if(preg_match('/^[A-Za-z0-9_\-]+(,[A-Za-z0-9_\-]+)*$/i', $loc)) {return preg_replace('/^/', '[\'', preg_replace('/$/', '\']', preg_replace('/,/', '\'][\'', $loc)));} else {throw new Exception("Invalid location path for multi-dimentional array");}} catch(Exception $e) {echo "<b>Fatal Error</b>: ".$e->getMessage()." on line ".$e->getLine()." of ".$e->getFile();exit();}}function marray_set(&$array, $loc, $value) {$value=(is_array($value))?var_export($value, true):"'".addslashes($value)."'";eval("\$array".marray_loc($loc)."={$value};");}function marray_get(&$array, $loc) {return eval("return \$array".marray_loc($loc).";");}function marray_count(&$array, $loc) {return eval("return count(\$array".marray_loc($loc).");");}function marray_is_empty(&$array, $loc) {return eval("return empty(\$array".marray_loc($loc).");");}function marray_is_set(&$array, $loc) {return eval("return isset(\$array".marray_loc($loc).");");}?>
|