Forum Moderators: coopster

Message Too Old, No Replies

variables and filter var array()

         

Jsyvanne

12:28 pm on Nov 26, 2009 (gmt 0)

10+ Year Member



Is this supposed to happen with filter_var_array()?:

$array = array ('field' => '<strong>testlink</strong>' );
$var = $array['field'];
echo $var.'<br>';
// $var contains array field value with html
$array = filter_var_array($array,FILTER_SANITIZE_STRING);
echo $var.'<br>';
// and now $var suddenly contains sanitized string

regular array manipulating works as expected (as I expected atleast)

$array2 = array ('field2' => 'value');
$var2 = $array2['field2'];
echo $var2.'<br>'; // 'value'
$array2['field2'] = 'test';
echo $var2; // still 'value' as it should be.

What am I missing?

TheMadScientist

4:37 am on Dec 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What am I missing?

Nothing based on the PHP variable manual [php.net] and the fact it's not happening for me when I copy and paste your code... You're obviously not assigning by reference, which is how it appears your version of PHP is treating the assignment.

Have you checked your PHP version to make sure you're on 5.2 or higher? If so, I would think you should either contact your host and/or file a PHP bug report.