0

I've got this nice script with a lot of help working:

   if (isset($_POST['talente'])) { // array(2) { [0]=> string(1) "2" [1]=> string(1) "3" } 

    $talente = $_POST['talente']; 

    $myFile = fopen("talente.csv", "r"); // e.f.: name;1;-;stuff
    $csv = [];
    while ($data = fgetcsv($myFile, 1000, ";")) {
        $csv[] = $data;
    }
    fclose($myFile);

    $i = 0;
    $talentline = array_filter($csv, function($i) use ($talente) {
        return in_array($i, $talente--);
    }, ARRAY_FILTER_USE_KEY);

    $talentline = array_filter($talentline);
    $talentline = array_values($talentline);

}

$talentline[0][0] = isset($talentline[0][0]) ? $talentline[0][0] : ""; 
...

This works very well on my PC in localhost. But after uploading it on my host nothing happened. After printing and dumping a while I noticed, that every variable has the expected value/s but $talentline. When I set var_dump around it, it gives me a multi-dimensional array back as I expect it on PC. But on my Hoster only NULL. I couldn't find out why.

16
  • If it works on one but not another, then check for errors php.net/manual/en/function.error-reporting.php then come back and add the error(s) in your question, should there be any. Could also be a permissions issue, PHP version, who knows. Commented Aug 28, 2016 at 16:57
  • Is $talente an array? If not, looks like it's an integer. php.net/in_array I don't see how your code would ever work. Commented Aug 28, 2016 at 16:58
  • No errors, not a single one. Yes, $talente is an array and as I wrote, it works on my personal localhost. Commented Aug 28, 2016 at 17:01
  • Then why do you try to decrement $talente -> return in_array($i, $talente--); Commented Aug 28, 2016 at 17:03
  • 2
    Have both envs local and remote got the same php version? Commented Aug 28, 2016 at 17:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.