tags:

views:

53

answers:

1

Why this doesn't work? if (array_search((string)$key,$list))

foreach ($head as $index => $key) 
        {
                if (array_search((string)$key,$list))
                {
                    $data[$index] = serialize($data[$index]);
                    $combined[$key] = isset($data[$index]) ? $data[$index] : null;
                } else {

                    $combined[$key] = isset($data[$index]) ? $data[$index] : null;
                }

        }  

$list is an array to search in

+1  A: 

Info from php.net:

array_search — Searches the array for a given value and returns the corresponding key if successful http://se.php.net/manual/en/function.array-search.php

try:

if($newKey = array_search((string)$key, $list))

By the way, you will get an notice on "$data", $data is not defined.

Br,
Paul Peelen

Paul Peelen
this doesn't work
Can you add more of your code or a link to a phps file or something? Update your question with the full code so its easy to read. /P
Paul Peelen