We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11975
    • 2,542 Posts
    Hi folks,

    I really need help cause I’m stuck.
    I don’t understand at all why I got this error.

    My function looks like this:

    <?php
    
    function handleValue($external,$allowed=array()){
    
    	$posted= array();
    	
    	if(!is_array($external)) return false;
    	
    		foreach($external as $key => $value){
    		
    			if(in_array($key,$allowed) || (strpos($key,implode("," ,$allowed))!==false)){
    				
    			
    				if((is_array($value)) && (strpos($key,"option") !== FALSE)){
    				
    					$posted['options'] = $this->handleOptionsValues($posted['options'],$key,$value);
    				
    				}else{
                               ///this part returns the error
    					$posted[$key] = $value;
    					
    				}
    			
    			}elseif(is_array($string = explode("_",$key)) && in_array($string[0],$allowed)){
    			
    				$posted[$string[0]][] = $value ;
    			}
    		}
    
    	return $posted;
    	
    	}
    
    


    It allows me to deal with GET and POST values submitted by a form and apply specific treatment according field name
    When my forms contains a listbox multi( an array of datas is sent => form field such as name="myMulti[]"), I systematically receive an array to string conversion error.
    The involved part of the function is
    ///this part returns the error
    $posted[$key] = $value;


    I don’t know at all why this happens.

    Any helps appreciated

    :-)
    sample $external data


    Array
    (
    [templateVarsTest] => Array
    (
    [0 ] => dummy content
    [1] => mooshow
    [2] => Recettes
    )

    [tvid] => 7
    [new_parent] => 0
    [id] => 8
    [a] => 112
    [action] => viewDoc
    [search] => Search


    Sample $allowed

    Array(
    [0 ]=>tvid
    [1]=> templateVarsTest
    ....
    )
      Made with MODx : [url=http://www.copadel.com]copadel, fruits et l
      • 11975
      • 2,542 Posts
      A little more info:

      What’s really wierd is that the error doesn’t affect the fornt office.
      The same function called from a module returns an error but not from the front end.

      Any clue ?


      :-)
        Made with MODx : [url=http://www.copadel.com]copadel, fruits et l