troubleshooting Question

htmlspecialchars not working permanently on array values

Avatar of Colin Brazier
Colin BrazierFlag for United Kingdom of Great Britain and Northern Ireland asked on
PHP
4 Comments1 Solution73 ViewsLast Modified:
I am trying to apply htmlspecialchars to data in a simple array.  The function "html" is set up to apply htmlspecialchars.

The data in the array seems to be unaffected after applying the function.

My debugging efforts are shown in the code.  The attached graphic is from view source.  So it seems to temporarily change Welling Town 'A' to Welling Town 'A' but when I print_r the whole array it has reverted to Welling Town 'A'

What am I missing here please?

echo("<pre>");
            print_r($arr_oppo);
			echo("</pre>");	
			
			if ($side == '4')
			{
				foreach ($arr_oppo AS $key=>$oppo_name)
				{
					echo "<br/>";
					echo "before: ".$oppo_name;
					echo "<br/>";
					$oppo_name = html($oppo_name);
					echo "after: ".$oppo_name;
					echo "<br/>";
				}	
			}
			
			echo("<pre>");
            print_r($arr_oppo);
			echo("</pre>");	

Open in new window

Capture.PNG
ASKER CERTIFIED SOLUTION
Zakaria Acharki
Analyst Developer
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros