mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 08:22:07 +02:00
added recursive addslashes
This commit is contained in:
parent
2585a68d54
commit
04480de386
@ -366,6 +366,35 @@ function stripslashes_recursive($var) {
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive implementation of addslashes()
|
||||
*
|
||||
* This function will allow you to add the slashes from a variable.
|
||||
* If the variable is an array or object, slashes will be added
|
||||
* to the items (or properties) it contains, even if they are arrays
|
||||
* or objects themselves.
|
||||
*
|
||||
* @param mixed the variable to add slashes from
|
||||
* @return mixed
|
||||
*/
|
||||
function addslashes_recursive($var) {
|
||||
if(is_object($var)) {
|
||||
$properties = get_object_vars($var);
|
||||
foreach($properties as $property => $value) {
|
||||
$var->$property = addslashes_recursive($value);
|
||||
}
|
||||
}
|
||||
else if(is_array($var)) {
|
||||
foreach($var as $property => $value) {
|
||||
$var[$property] = addslashes_recursive($value);
|
||||
}
|
||||
}
|
||||
else if(is_string($var)) {
|
||||
$var = addslashes($var);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given some normal text this function will break up any
|
||||
* long words to a given size by inserting the given character
|
||||
|
Loading…
x
Reference in New Issue
Block a user