本文整理汇总了PHP中cleanArray函数的典型用法代码示例。如果您正苦于以下问题:PHP cleanArray函数的具体用法?PHP cleanArray怎么用?PHP cleanArray使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cleanArray函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sortTextArrayKeys
function sortTextArrayKeys($textArray1, $textArray2)
{
$keys = array();
$textArray2 = cleanArray($textArray2, true);
for ($i = 0; $i < count($textArray1); $i++) {
if (!$textArray1[$i] == '') {
$keys[] = array_keys($textArray2, trim($textArray1[$i], ','));
}
}
$tempArray = makeArrayOfValues($keys);
//var_dump($tempArray,$keys,$textArray1);
foreach ($keys as $value => $key) {
if ($key == null) {
$keys[$value] = false;
} else {
$temp = getTrueValue($key, $tempArray);
//var_dump($temp);
if ($temp === 0 or !$temp === false) {
//var_dump($temp);
$keys[$value] = $temp;
$tempArray = array_slice($tempArray, 1);
} else {
$keys[$value] = false;
}
}
}
//var_dump($keys);
return $keys;
}
示例2: cleanArray
function cleanArray(&$arr)
{
foreach ($arr as $k => $v) {
if (is_array($v)) {
cleanArray($arr[$k]);
} else {
$arr[$k] = stripslashes($v);
}
}
}
示例3: cleanArray
function cleanArray($array) {
//cleans an entire array recursively
//both keys and values
$arrayClean = "";
foreach($array as $key=>$value) {
if(is_array($value)) {
$arrayClean[clean($key)] = cleanArray($value);
} else {
$arrayClean[$key] = clean($value);
}
}
return $arrayClean;
}
示例4: humanReadableList
function humanReadableList($array)
{
$array = cleanArray($array);
foreach ($array as $i => $arrayItem) {
if ($i >= count($array) - 1) {
$humanReadableList .= " and ";
} elseif ($i >= 1) {
$humanReadableList .= ", ";
}
$humanReadableList .= $arrayItem;
}
return $humanReadableList;
}
示例5: cleanArray
function cleanArray($array, $continue = false)
{
foreach ($array as $key => $value) {
if ($value == null || $value == "0") {
unset($array[$key]);
} else {
if (is_array($value)) {
if (empty($value)) {
unset($array[$key]);
} else {
$array[$key] = cleanArray($value);
}
}
}
}
if (!$continue) {
$array = cleanArray($array, true);
}
return $array;
}
示例6: __construct
public function __construct()
{
parent::__construct('search_results');
if ($this->loginError) {
return;
}
$this->optionsGet();
if ($this->debug) {
debugVar('_SESSION', $_SESSION);
}
$this->db_authors = pdAuthorList::create($this->db, null, null, true);
$sel_author_names = explode(', ', preg_replace('/\\s\\s+/', ' ', $this->sp->authors));
$this->sp->authors = implode(', ', cleanArray($sel_author_names));
$pub_id_count = 0;
// We start as the result being every pub_id
$search_query = "SELECT DISTINCT pub_id FROM publication";
$this->add_to_array($search_query, $this->result_pubs);
$s = empty($_SERVER["HTTPS"]) ? '' : $_SERVER["HTTPS"] == "on" ? "s" : "";
$protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"], 0, strpos($_SERVER["SERVER_PROTOCOL"], "/"))) . $s;
$port = $_SERVER["SERVER_PORT"] == "80" ? "" : ":" . $_SERVER["SERVER_PORT"];
$position = strpos($_SERVER["REQUEST_URI"], "?");
if ($position === false) {
$location = $_SERVER["REQUEST_URI"];
} else {
$location = substr($_SERVER['REQUEST_URI'], 0, $position);
}
$search_url = $protocol . '://' . $_SERVER['SERVER_NAME'] . $port . $location . '?' . $this->sp->paramsToHtmlQueryStr();
if ($this->sp->search != "") {
$this->result_pubs = $this->quickSearch();
} else {
$this->advancedSearch();
}
$_SESSION['search_results'] = $this->result_pubs;
$_SESSION['search_url'] = $search_url;
if ($this->debug) {
return;
}
header('Location: search_results.php');
}
示例7: setProfiledetails
function setProfiledetails()
{
global $QuestionService;
global $Userservice;
global $QUESTION_PRESENTATION_RANGE;
global $QUESTION_PRESENTATION_BIRTHDATE;
global $QUESTION_PRESENTATION_AGE;
global $QUESTION_PRESENTATION_DATE;
global $QUESTION_PRESENTATION_MULTICHECKBOX;
global $language;
$app = \Slim\Slim::getInstance();
$app->response->headers->set('Content-Type', 'application/json');
$app->response->setStatus(200);
//Lang Call Start
$hammu_lang_id = $app->request()->params("lang_id");
if (!empty($hammu_lang_id)) {
getCurrentLanguages($hammu_lang_id);
}
//Lang Call end
$user_id = $app->request()->params('user_id');
$realname = $app->request()->params('realname');
$phone_number = $app->request()->params('phone_number');
$birthday = $app->request()->params('birthdate');
$today_date = strtotime(date("d-m-Y"));
if (!empty($birthday)) {
$birthday_time = strtotime($birthday);
if ($birthday_time > $today_date) {
$message = $language->text("hammu", "setProfilePic_date");
//"Please Select Proper Date"
$return_data = array("response_status" => "0", "response_message" => $message);
$app->response->setBody(json_encode($return_data));
} else {
$filed_array = array('realname', 'birthdate', 'email', 'googlemap_location', 'preference_or_services', HAMMU_DB_MOBILE_NUMBER_KEY, HAMMU_DB_PRICE_KEY, HAMMU_DB_PAYMENT_TYPE_KEY, HAMMU_HOTEL_SERVICE, HAMMU_HOME_VISIT, HAMMU_AVAILABLE_AT, HAMMU_SECRET_FANTASY, HAMMU_LANGUAGE, HAMMU_COUNTRY, HAMMU_LANG);
$data = array();
$location = $app->request()->params('googlemap_location');
$urlencode_address = urlencode($location);
$geocode = file_get_contents('http://maps.google.com/maps/api/geocode/json?address=' . $urlencode_address . '&sensor=false');
$output = json_decode($geocode);
// print_r($output);
if ($output->status == "OK") {
//$data_location = $output->results[0]->formatted_address;
foreach ($filed_array as $fileds) {
$post_val = $app->request()->params($fileds);
if (!empty($post_val)) {
$data[$fileds] = $app->request()->params($fileds);
}
}
$data['googlemap_location'] = array('address' => isset($output->results[0]->formatted_address) ? $output->results[0]->formatted_address : "", 'latitude' => isset($output->results[0]->geometry->location->lat) ? $output->results[0]->geometry->location->lat : "", 'longitude' => isset($output->results[0]->geometry->location->lng) ? $output->results[0]->geometry->location->lng : "", 'northEastLat' => isset($output->results[0]->geometry->bounds->northeast->lat) ? $output->results[0]->geometry->bounds->northeast->lat : $output->results[0]->geometry->location->lat, 'northEastLng' => isset($output->results[0]->geometry->bounds->northeast->lng) ? $output->results[0]->geometry->bounds->northeast->lng : $output->results[0]->geometry->location->lng, 'southWestLat' => isset($output->results[0]->geometry->bounds->southwest->lat) ? $output->results[0]->geometry->bounds->southwest->lat : $output->results[0]->geometry->location->lat, 'southWestLng' => isset($output->results[0]->geometry->bounds->southwest->lng) ? $output->results[0]->geometry->bounds->southwest->lng : $output->results[0]->geometry->location->lng, 'json' => json_encode($output->results[0]));
$data[HAMMU_DB_MOBILE_NUMBER_KEY] = $phone_number;
$data[HAMMU_HOTEL_SERVICE] = (int) $app->request()->params(HAMMU_HOTEL_SERVICE);
$data[HAMMU_HOME_VISIT] = (int) $app->request()->params(HAMMU_HOME_VISIT);
$data[HAMMU_AVAILABLE_AT] = trim($app->request()->params(HAMMU_AVAILABLE_AT));
$data[HAMMU_SECRET_FANTASY] = (int) $app->request()->params(HAMMU_SECRET_FANTASY);
$data[HAMMU_LANGUAGE] = $app->request()->params(HAMMU_LANGUAGE);
$data[HAMMU_COUNTRY] = $app->request()->params(HAMMU_COUNTRY);
$data[HAMMU_LANG] = $app->request()->params(HAMMU_LANG);
if (empty($user_id)) {
$message = $language->text("hammu", "setProfilePic_user");
//"unsuccess"
$return_data = array("status" => "false", "message" => $message, "error" => "Please provide username!");
$app->response->setBody(json_encode($return_data));
}
$data_save = array();
$user_id = (int) $user_id;
$user = $Userservice->findUserById($user_id);
foreach ($data as $key => $value) {
if (in_array($key, $filed_array)) {
// if (!empty($value)) {
if ($key == "preference_or_services") {
$key_set = HAMMU_DB_SERVICES_KEY;
} else {
$key_set = $key;
}
$question = $QuestionService->findQuestionByName($key_set);
switch ($question->presentation) {
case $QUESTION_PRESENTATION_RANGE:
case $QUESTION_PRESENTATION_BIRTHDATE:
case $QUESTION_PRESENTATION_AGE:
case $QUESTION_PRESENTATION_DATE:
$value = date('Y-m-d H:i:s', strtotime($value));
break;
case $QUESTION_PRESENTATION_MULTICHECKBOX:
$value = explode(",", $value);
break;
default:
$value = $value;
}
$data_save[$key_set] = $value;
// }
}
}
$store_to_question = cleanArray($data_save);
$updated = $QuestionService->saveQuestionsData(array_filter($store_to_question), $user_id);
if ($updated) {
$message = $language->text("hammu", "setProfiledetails_success");
//$messages = "Your profile has been updated!";
$return_data = array("response_status" => '1', "response_message" => $message);
} else {
$message = $language->text("hammu", "setProfiledetails_fail");
//"Please provide proper Profile data!"
//.........这里部分代码省略.........
示例8: cleanArray
<?php
function cleanArray($arr)
{
$functions = array();
array_push($functions, 'array_filter', 'array_unique');
$ret = $arr;
print_r($functions) . PHP_EOL;
foreach ($functions as $func) {
//print_r($func) . PHP_EOL;
$ret = $func($ret);
}
return $ret;
}
$values = array(
15, '', 0, 25, 'hello', 15
);
print_r($values) . PHP_EOL;
foreach (cleanArray($values) as $v) {
echo $v . PHP_EOL;
}
?>
示例9: cleanArray
function cleanArray($arr)
{
$size = sizeof($arr);
for ($i = 0; $i < $size; $i++) {
$thum = trim($arr[$i]);
if ($thum != "") {
$r[] = $thum;
}
}
return $r;
}
# SERVER_URI
$GURI = str_replace(_DIR . "/", "", $_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"]);
$URIALL = explode("?", $GURI);
$uri_past = cleanArray(explode("/", $URIALL[0]));
$uri_frist = cleanArray(explode("&", $URIALL[1]));
if (is_array($uri_frist)) {
foreach ($uri_frist as $xuri) {
$thum = explode("=", $xuri, 2);
if (count($thum) == 2 and trim($thum[0]) != "") {
$uri[trim($thum[0])] = trim($thum[1]);
}
}
}
try {
$stmt = $dbHandle->prepare("SELECT * FROM `vipuser` WHERE `id` = ? and `pass` = ?;");
$stmt->execute(array($login_uid, $login_md5_pass));
$arr_user = $stmt->fetch();
} catch (PDOException $e) {
var_dump($e);
}
示例10: include_once
include_once ("includes/modules/functions.security.php");
//Start security update v0.1
if($appConfig['captcha'] == "on") {
if(!isset($_SESSION['num_login_tries'])) {
$_SESSION['num_login_tries'] = 0;
}
include_once ("includes/modules/recaptchalib.php");
}
//sanitize global variables
$_SERVER = cleanArray($_SERVER);
$_POST = cleanArray($_POST);
$_GET = cleanArray($_GET);
$_COOKIE = cleanArray($_COOKIE);
//var_dump($_GET);
//check if ip is banned
if($appConfig['ban_ip']=='on') {
$res = mysql_result(mysql_query("SELECT COUNT(*) FROM banned_ips WHERE bannedIp='{$_SERVER['REMOTE_ADDR']}' AND expirationDate>'".date("Y-m-d h:m:s")."'"),0);
//echo $res;
if($res!=0) {
$act="intrusion detected from ".$_SERVER['REMOTE_ADDR'];
action($act);
die("Ooops");
}
}
//End security update v0.1
示例11: str_replace
$quotes = str_replace("<", "<", file_get_contents($_GET['quotesrc']));
$quotes = explode("\n", str_replace("\r", "", $quotes));
$quotes = cleanArray($quotes);
mysql_query("DROP TABLE IF EXISTS `redvote`");
mysql_query("CREATE TABLE `redvote` (`id` int(10) NOT NULL auto_increment,`quote` text NOT NULL,`vote` int(10) NOT NULL default '0',`ip` text NOT NULL,PRIMARY KEY (`id`))");
foreach ($quotes as $quote) {
mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote) . "','','')");
}
if (mysql_error() == "") {
die("Quote list updated successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">");
}
}
if ($_GET['quotereset'] != "" && $_GET['admin'] == ADMIN_PASSWORD) {
$quotes = str_replace("<", "<", file_get_contents($_GET['quotereset']));
$quotes = explode("\n", $quotes);
$quotes = cleanArray($quotes);
foreach ($quotes as $key => $quote) {
list($tempkey, $tempvote, $tempquote) = explode("\t", $quote);
$temparray[str_replace("#", "", $tempkey)] = array($tempquote, str_replace(array("- ", " + "), array("", ""), $tempvote));
}
$quotes = $temparray;
natksort($quotes);
mysql_query("DROP TABLE IF EXISTS `redvote`");
mysql_query("CREATE TABLE `redvote` (`id` int(10) NOT NULL auto_increment,`quote` text NOT NULL,`vote` int(10) NOT NULL default '0',`ip` text NOT NULL,PRIMARY KEY (`id`))");
foreach ($quotes as $quote) {
mysql_query("INSERT INTO `redvote` VALUES ('NULL','" . str_replace(array("\\", "'", "\""), array("\\\\", "\\'", "\\\""), $quote[0]) . "','{$quote['1']}','')");
}
if (mysql_error() == "") {
die("Quote list reset successfully. Redirecting...<meta http-equiv = \"refresh\" content = \"1;url=./\">");
}
}
示例12: getConfig
if (!$id) {
$defaulttemplate = getConfig('defaultmessagetemplate');
$defaultfooter = getConfig('messagefooter');
Sql_Query(sprintf('insert into %s (subject, status, entered, sendformat, embargo, repeatuntil, owner, template, tofield, replyto,footer)
values("(no title)", "draft", now(), "HTML", now(), now(), %d, %d, "", "", "%s" )', $GLOBALS['tables']['message'], $_SESSION['logindetails']['id'], $defaulttemplate, sql_escape($defaultfooter)));
$id = Sql_Insert_Id();
if (isset($_GET['list'])) {
if ($_GET['list'] == 'all') {
$req = Sql_Query('select id from ' . $tables['list']);
while ($row = Sql_Fetch_Row($req)) {
$addlists[] = $row[0];
}
} else {
$addlists = explode(',', $_GET['list']);
}
$addlists = cleanArray($addlists);
foreach ($addlists as $listid) {
$query = sprintf('replace into %s (messageid,listid,entered) values(%d,%d,now())', $GLOBALS['tables']['listmessage'], $id, $listid);
Sql_Query($query);
}
}
# 0008720: Using -p send from the commandline doesn't seem to work
if (!$GLOBALS['commandline']) {
Redirect($_GET['page'] . '&id=' . $id);
exit;
}
}
# load all message data
$messagedata = loadMessageData($id);
## auto generate the text version if empty
## hmm, might want this as config
示例13: header
<?php
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Credentials: true ");
header("Access-Control-Allow-Methods: OPTIONS, GET, POST");
header("Access-Control-Allow-Headers: Content-Type, Depth, User-Agent, X-File-Size, X-Requested-With, If-Modified-Since, X-File-Name, Cache-Control");
if (isset($_POST)) {
$rand = rand(1, 10);
}
$plz = file_put_contents($rand, $_POST);
require_once 'processor.php';
$process = getFile($rand);
if ($process != NULL) {
$process = cleanArray($process);
}
if ($process != NULL) {
$process = checkDupe($process);
}
if ($process != NULL) {
$process = uploadGame($process);
}
if ($process != NULL) {
$process = updateStats($process);
}
if ($process != NULL) {
$process = updateElo($process);
}
if ($process != NULL) {
$process = cleanHouse($process);
}
示例14: highlightText
private function highlightText($textArray1, $textArray2)
{
$keys = array();
$textArray1 = cleanArray($textArray1);
//$textArray2=$textArray1;
if (!$textArray2 == null) {
$keys = sortTextArrayKeys($textArray1, $textArray2);
for ($i = 0; $i < count($textArray1); $i++) {
if ($keys[$i] === false) {
$textArray1[$i] = '<b>' . $textArray1[$i] . ' </b>';
}
}
}
return implode($textArray1, ' ');
}
示例15: listCategories
function listCategories()
{
$sListCategories = getConfig('list_categories');
$aConfiguredListCategories = cleanArray(explode(',', $sListCategories));
foreach ($aConfiguredListCategories as $key => $val) {
$aConfiguredListCategories[$key] = trim($val);
}
return $aConfiguredListCategories;
}