1

This works fine...

$row = array_map("html_entity_decode", $row);

BUT, I need to add the ENT_QUOTES flag and I cannot get it to work. Any ideas?

$row = array_map("html_entity_decode, ENT_QUOTES", $row);
0

3 Answers 3

0

You can use a lambda function notation like this (PHP 7.4+)

$row = array_map(fn($e) => html_entity_decode($e, ENT_QUOTES), $row);

Before PHP 7.4 just use the normal anonymous function

$row = array_map(function($e) { return html_entity_decode($e, ENT_QUOTES); }, $row);
Sign up to request clarification or add additional context in comments.

5 Comments

Any solution for 5.6?
@ScottWeisberg For sure, just the old notation. Answer updated.
The solution for PHP5.6 = upgrade to a supported php version.
@MarkusZeller Please help us to close duplicate questions.
PHP's array_map() supports a third parameter which is an array representing the parameters to pass to the callback function.
0

This seems to do it...

    function myFunc($a) {
    return html_entity_decode($a, ENT_QUOTES);
    }

    $row = array_map("myFunc", $row);

Comments

-1

You can try with array_walk_recursive

array_walk_recursive($yourArray, function (&$value) { $value = html_entity_decode($value, ENT_QUOTES); });

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.