Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/cc/cc_lib/gral_lib/functions.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00039 function errorHandler($errno, $errstr, $errfile, $errline) {
00040     // si deseas podes guardarlos en un archivo
00041     ($errfile);($errline);
00042     throw new Exception($errstr, $errno);
00043 }
00044 
00045 
00046 
00054 function file_mime_type ($file, $default_type = 'application/octet-stream'){
00055     $ftype = $default_type;
00056     $magic_path =   dirname(__FILE__)
00057                   . DIRECTORY_SEPARATOR
00058                   . '..'
00059                   . DIRECTORY_SEPARATOR
00060                   . 'magic'
00061                   . DIRECTORY_SEPARATOR
00062                   . 'magic';
00063     $finfo = @finfo_open(FILEINFO_MIME , $magic_path);
00064     if ($finfo !== false) {
00065 
00066         $fres = @finfo_file($finfo, $file);
00067 
00068         if ( is_string($fres) && !empty($fres) ) {
00069             $ftype = $fres;
00070         }
00071         @finfo_close($finfo);
00072     }
00073     return $ftype;
00074 }
00075 
00076 
00077 
00078 
00079 function array_remove_by_value($arr,$value) {
00080     return array_values(array_diff($arr,array($value)));
00081 
00082 }
00083 
00084 
00085 function array_remove_by_key($arr,$key) {
00086     return array_values(array_diff_key($arr,array($key)));
00087 
00088 }
00089 
00090 
00091 function cc_print_object($object) {
00092     echo '<pre>' . htmlspecialchars(print_r($object,true)) . '</pre>';
00093 }
00094 
00095 
00096 
00105 function indexOf($needle, $haystack) {
00106     for ($i = 0; $i < count($haystack) ; $i++) {
00107             if ($haystack[$i] == $needle) {
00108                 return $i;
00109             }
00110     }
00111     return false;
00112 }
00113 
00114 
00123 function indexOf2($needle, $haystack) {
00124     for($i = 0,$z = count($haystack); $i < $z; $i++){
00125         if ($haystack[$i] == $needle) {  //finds the needle
00126             return $i;
00127         }
00128     }
00129     return false;
00130 }
00131 
 All Data Structures Namespaces Files Functions Variables Enumerations