0

I want to escape an array in php

I try to escape with addslashes function but it doesn't work

 while($row = $res->fetch_assoc()) 
    {
        $row['name']=addslashes($row['agente']); //escape ?
        $rows[] = $row;
    }

I want to escape the name of a person call 'Antonio cinà' but it doesn't work The problem is 'à'

hamid
  • 11
  • 6

2 Answers2

0

Use htmlentities() php function to escape special characters.

while($row = $res->fetch_assoc()) {
        $row['name']= htmlentities($row['agente']); //escape ?

    }

PHP Manual for htmlentities

Vidal
  • 2,605
  • 2
  • 16
  • 32
0

You also use htmlspecialchars() instead of htmlentities() to escape the array string.

while($row = $res->fetch_assoc()) {
    $row['name']= htmlspecialchars($row['agente']); //escape ?
    $rows[] = $row;
}