0

i'm using zend_tables for my model and i'd like to create a function to convert all data from a single row (retireved like this: $row = $model->find($id)) to htmlentities before outputting it with the usual code:

echo ($row->current()->nameOfField);

I need something like this function i use on arrays:

public static function convertArrayToHtmlEntities($data){


        $keys = array_keys($data);

        foreach ($keys as $k) {


            $d = $data[$k];

            $clean = htmlentities($d, ENT_QUOTES, "UTF-8");

            $data[$k] = $clean;
        }


        return $data;
    }

Thx in advance!

Nicola Peluchetti
  • 76,206
  • 31
  • 145
  • 192
  • Why not just convert zend_db_row to array `$row->toArray()`, and use your function? – Marcin May 02 '11 at 13:11
  • Actually i also have a function that decodes objects...i could cycle on row->current() and convert everything, i just wanted to be sure to convert only properties of $row->current() and not other parts! – Nicola Peluchetti May 02 '11 at 14:58

1 Answers1

0

If you're using Zend View you can just escape the output in your view script. See Escaping Output.

If you're not using it in a view script you can use Zend Filter.

jamesj2
  • 16
  • 1