Jump to content

Recommended Posts

I have tried both:

array_walk(&$files, 'htmlentities');
array_walk($files, 'htmlentities');

 

Using PHP5

 

Nothing changes, it still prints & instead of &

Do I have to wrap htmlentities in a in a custom function or am I doing something wrong?

 

EDIT:

I tried wrapping it in a function and no change.

$h = create_function('$txt', 'return htmlentities($txt);');
array_walk(&$files, $h);
print_r($files);

 

Array

(

    [28] => panels/DC_air & space #2.jpg

    [29] => panels/DC_air & space #3.jpg

    [30] => panels/DC_air & space.jpg

)

You have an extra $ in there, but after I removed it it still didn't work.

Still got:

    [28] => panels/DC_air & space #2.jpg

    [29] => panels/DC_air & space #3.jpg

    [30] => panels/DC_air & space.jpg

This works:

 

<?php

$arr = array('panels/DC_air & space #2.jpg', 'panels/DC_air & space #3.jpg', 'panels/DC_air & space.jpg');

function alter(&$arr_item){
    $arr_item = htmlentities($arr_item);
}

array_walk($arr, 'alter');
print_r($arr);
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.