Fatal error: Call to undefined function: array_combine()

I need help!!


$headings = array();
$listings = array();

        $handle = fopen(LOCAL_WORKING_DIR ."listings-single family.txt","r") or die("trouble");
        $line = fgets($handle, 4096);
        if(!feof($handle))
        {
            $headings = explode("t", $line);
        }
        
        $line = fgets($handle, 4096);
        while(!feof($handle))
        {
            $pieces = array();
            $pieces = explode("t", $line);

            $a = count($headings);
            $b = count($pieces);
            if($a < $b)
            {
                if($dataToggle == true)
                {
                    $dataToggle = false;
                    echo "<span style="color: red;">There is a problem with the data in " . substr($file, 0, -3) . "! Attempting to Reslove!</span><br>n";
                }
                $c = $b - $a;
                for($t=0; $t<$c; $t++)
                    array_push($headings, " ");
            }
            if($a > $b)
            {
                if($dataToggle == true)
                {
                    $dataToggle = false;
                    echo "<span style="color: red;">There is a problem with the data in " . substr($file, 0, -3) . "! Attempting to Reslove!</span><br>n";
                }
                $c = $a - $b;
                for($t=0; $t<$c; $t++)
                    array_push($pieces, " ");
            }
            
            $temp = array_combine($headings, $pieces) or die('Fatal Error: corrupt data in file ' . substr($file, 0, -3));
            
            if(strcmp(CLIENT_OFFICE, $temp["List Office"]) == 0)
            {
                array_push($listings, $temp);
            }
            $line = fgets($handle, 4096);       
        }
       
    }
    echo "Succesfully processed data in file " . substr($file, 0, -3) . "<br>n";
}

what version of php are u using?
array_combine needs php5: http://php.net/array_combine

try:
[php]
if(!function_exists(‘array_combine’))
{
function array_combine($keys, $values)
{
if(!count($keys) || !count($values) || count($keys)!=count($values)) return false;
$result = array() ;
while( ($k=each($keys)) && ($v=each($values)) ) $result[$k[1]] = $v[1] ;
return $result ;
}
}
[/php]
thx2Fred

this function definition has to be at the top of the array_combine call!

u posted something new.

how did this work out?
would be nice to get some feedback (not for me, but for those having the same prob in the future).
thx

Sponsor our Newsletter | Privacy Policy | Terms of Service