Excessive use of function

I am displaying tabular data of about 10 different columns and each column is being displayed with an ID similar to this:

<td><a href="?e=<?php htmlout($chemical['id']); ?>"><?php htmlout($chemical['id']); ?></a></td>

htmlout is a custom function that just runs it through htmlspecial characters and echos it (as seen in Kevin’s book).

Anyway, it loops through about 1000 records doing this. It seems to me that running everything through that function might be improper or slowing things down than what it could be.

Is there a way to just cleanse the entire array so I don’t have to htmlspecialchars() everytime I echo something out?

Of course :slight_smile:

I don’t really see the point in a function merely echoing the result of another function, but each to their own.

What you’d do is use array_map():

$clean = array_map('htmlspecialchars', $chemical);

Perfect, thanks.

I’m still new to PHP (or programming in general) so I’m just following along with the book at the moment.