function secure_loop($obj, $param = null) { if (is_jsoned($obj)) { $copy = $obj; foreach ($copy as &$item) { $item = secure_text($item, $param); } $obj = $copy; } return $obj; }
function string_values($arr, $var = null, $par = null) { $str = ''; $mode = is_assoc_array($arr) && $par == null ? true : false; if ($mode) { $par = $var; } $custom = array('separ' => ',', 'empty' => 'NULL', 'middle' => '=', 'body' => "'", 'json' => false); $custom = set_merge($custom, $par); $arr = take_good_array($arr, true, $custom['json']); if (!$mode) { $var = take_good_array($var, false, $custom['json']); if (count($arr) == 1 && count($var) > 1) { $var = array(json_val_encode($var)); } } $L = get_last_key($arr); $i = 1; if (!$mode && $var) { $B = count($arr) < count($var) ? count($arr) : count($var); } else { $B = count($arr); } foreach ($arr as $key => $item) { if ($i <= $B) { $item1 = $item2 = null; if ($mode) { $item1 = $key; $item2 = $item; } elseif (isset($var[$key])) { $item1 = $item; $item2 = $var[$key]; } if (is_jsoned($item1)) { $item1 = json_val_encode($item1); } if (is_jsoned($item2)) { $item2 = json_val_encode($item2); } $str .= "{$item1}{$custom['middle']}{$custom['body']}{$item2}{$custom['body']}"; if ($key != $L && $i < $B) { $str .= $custom['separ']; } $i++; } } return $str; }