Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
$result = $stmt->fetchAll(PDO::FETCH_COLUMN);
   if($result)
            return get_item_name(explode(' ','-1','0', $result[0]));
   else {
        return 'Empty';
        }


Warning: explode() expects at most 3 parameters, 4 given in vault.php on line 43

get_item_name_locale_name is other function that give names to each number


Database Column Data [6673 6669 4860 6670 -1 6671 6672 169 166 173 -1 -1 15 15 18 15 0 15 15 0 0 0 0 0]
"space","0","-1" must be ignored , somehow bigger than 1 must show


Thank you very much

What I have tried:

 if ($result) {
    return array_map(function ($row) {
        get_item_name_locale_name($row);
    }, $result);
} else {
    return '---';
}


i got error Notice: Array to string conversion in vault.php on line 57 Array
Posted
Updated 30-Dec-21 9:47am
v2

1 solution

Quote:
Warning: explode() expects at most 3 parameters, 4 given in vault.php on line 43
Your code, 4 parameters:
explode(' ','-1','0', $result[0])

vs. PHP: explode - Manual[^] 3 parameters
explode(string $separator, string $string, int $limit = PHP_INT_MAX): array

I think should be easy for you to solve. I hope it helps.
 
Share this answer
 
v3
Comments
Daniel Stan 30-Dec-21 16:18pm    
thank you for solution, $makeit = explode(" ", $result[0]); now how i ignore 0 and -1 ?
and must important how to return get_item_name($makeit); ? or shoud i use ?php print getItem(get_item_name($row['a_wearing'])); ?>
0x01AA 30-Dec-21 16:38pm    
First: Thank you very much for accepting.
Scnd: Now you're breaking my neck. I have very little idea about php, sorry :(
I hope this could maybe help you: PHP: How to use array_filter() to filter array keys? - Stack Overflow[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900