You are here

function stripslashes_safe in Quiz 6.6

Same name and namespace in other branches
  1. 6.5 includes/moodle_support.php \stripslashes_safe()
2 calls to stripslashes_safe()
questions_import_moodle_create_node in includes/questions_import/questions_import.admin.inc
s in includes/moodle_support.php

File

includes/moodle_support.php, line 266

Code

function stripslashes_safe($mixed) {

  // there is no need to remove slashes from int, float and bool types
  if (empty($mixed)) {

    //nothing to do...
  }
  else {
    if (is_string($mixed)) {

      //the rest, simple and double quotes and backslashes
      $mixed = str_replace("\\'", "'", $mixed);
      $mixed = str_replace('\\"', '"', $mixed);
      $mixed = str_replace('\\\\', '\\', $mixed);
    }
    else {
      if (is_array($mixed)) {
        foreach ($mixed as $key => $value) {
          $mixed[$key] = stripslashes_safe($value);
        }
      }
      else {
        if (is_object($mixed)) {
          $vars = get_object_vars($mixed);
          foreach ($vars as $key => $value) {
            $mixed->{$key} = stripslashes_safe($value);
          }
        }
      }
    }
  }
  return $mixed;
}