Add validation for the parameters in the array_diff function

This commit is contained in:
Julio Cesar Laura
2012-10-10 12:52:43 -04:00
parent 2c744ed4cc
commit bfff26b2c1

View File

@@ -1845,6 +1845,14 @@ $output = $outputHeader.$output;
* to iterate through the edited array, and I didn't need to original keys for anything. * to iterate through the edited array, and I didn't need to original keys for anything.
*/ */
function arrayDiff($array1, $array2) { function arrayDiff($array1, $array2) {
if (!is_array($array1)) {
$array1 = (array) $array1;
}
if (!is_array($array2)) {
$array2 = (array) $array2;
}
// This wrapper for array_diff rekeys the array returned // This wrapper for array_diff rekeys the array returned
$valid_array = array_diff($array1,$array2); $valid_array = array_diff($array1,$array2);
@@ -2046,11 +2054,11 @@ $output = $outputHeader.$output;
/** /**
* Replace Grid Values * Replace Grid Values
* The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid, * The tag @>GRID-NAME to open the grid and @<GRID-NAME to close the grid,
* *
* @param type String $sContent * @param type String $sContent
* @param type Array $aFields * @param type Array $aFields
* @return type String * @return type String
*/ */
function replaceDataGridField($sContent, $aFields) function replaceDataGridField($sContent, $aFields)
{ {