We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 400
    • 40 Posts
    Check if a value $_REQUEST[’pic’] exists in an array $pics[’id’]

    Error :

    
      Error: 	getimagesize() [function.getimagesize]: Read error!	 
      Error type/ Nr.: 	Warning - 2	 
      File: 	...assets/snippets/maxigallery/maxigallery.php	 
      Line: 	764	 
      Line 802 source: 	$imagesize=getimagesize($modx->config['base_path'].$mg->path_to_gal.$pics[$i]['filename']); 	 
    
    



    quick fix:

    
    	function mg_in_arrayr($needle, $haystack) {
    	
    		foreach ($haystack as $v) 
    		{
    				if ($needle == $v) 
    				{
    					return true;
    				}
    				elseif (is_array($v)) 
    				{
    					if (in_arrayr($needle, $v) === true) 
    					{
    						return true;
    					}
    				}
    		}
    		return false;
    	}
    	
    	$pics_id = array();
    	foreach($pics as $pic) {		
    			array_push($pics_id, $pic['id']);
    	}
    	
    	if (in_arrayr($request_pic, $pics_id) == false) {
    		$request_pic = $pics['id'];
    	}