本文整理汇总了PHP中ArrayHelper::arrayTrim方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::arrayTrim方法的具体用法?PHP ArrayHelper::arrayTrim怎么用?PHP ArrayHelper::arrayTrim使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::arrayTrim方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createReaction
public function createReaction()
{
$this->result = array();
$data = explode("\n", $this->fc->getReqVar('data'));
ArrayHelper::arrayTrim($data);
$t = count($data);
// total to parse
$i = 0;
// successfully parsed counter
$defDate = '';
// date of previous created task
$defValue = '';
// default value for multiple tasks creation (set by *)
foreach ($data as $val) {
if ($objTask = TaskModel::parse($val, $defValue, $defDate)) {
// really creating a task
$objTask->connectDb();
if ($objTask->check($this->switch_id)) {
$objTask->insert();
$i++;
}
}
}
$this->fc->redirect($this->fc->getUrl('task', 'main'), 'created');
// -TODO- show $i
}
示例2: parse
/**
* parse a single line string for task params
* @return a task object
*/
public static function parse($str, &$def, &$dte)
{
if (!preg_match('/^(\\* |\\*{2,3})?([+|-][0-9]{0,2}|[0-9]{2}\\/[0-9]{2})?( ?[0-9]+\\))?(.+)?$/', $str, $arr)) {
return false;
}
ArrayHelper::arrayTrim($arr);
$obj = new TaskModel();
$tst = empty($arr[1]) ? substr($arr[2], 0, 1) : '*';
switch ($tst) {
case '*':
// multiple
if ($arr[1] == '**') {
// reset default date (**)
$dte = '';
} else {
if ($arr[1] == '***') {
// reset default title (***)
$def = '';
} else {
if ($arr[2]) {
// remember date
if ($tst == '+') {
if ($n = substr($arr[2], 1)) {
// number of days later
$obj->set('deadline', $arr[2] . ' days');
} else {
// no number, means today
$obj->set('deadline', APP_SQL_TODAY);
}
} else {
$dte = $arr[2];
}
}
if ($arr[4]) {
// remember title
$def = $arr[4];
}
}
}
return false;
break;
case '-':
// no deadline
$obj->set('deadline', '9999-00-00');
break;
case '+':
// specify deadline
if ($n = substr($arr[2], 1)) {
// number of days later
$obj->set('deadline', $arr[2] . ' days');
} else {
// no number, means today
$obj->set('deadline', date_format(new DateTime('now', $GLOBALS['config']['datetime']['timezone_user']), 'Y-m-d'));
}
break;
default:
if ($arr[2]) {
// specific date set
$obj->set('deadline', $arr[2]);
$dte = $obj->get('deadline');
} else {
if (!empty($dte)) {
// use default date (from batch)
$obj->set('deadline', $dte);
} else {
if ($GLOBALS['config']['task']['date']) {
// use default date (config)
$obj->set('deadline', date_format(new DateTime($GLOBALS['config']['task']['date'], $GLOBALS['config']['datetime']['timezone_user']), 'Y-m-d'));
// $dte = $obj->get('deadline');
} else {
// no date by default (config)
$dte = '';
}
}
}
}
$prio = $GLOBALS['config']['task']['priority']['default'];
// default priority
if ($arr[3]) {
// priority ?
$prio = intval(substr($arr[3], 0, -1));
}
$obj->set('priority', $prio);
$title = $arr[4];
if ($def) {
$title = $def . ' : ' . $title;
}
$obj->set('title', $title);
return $obj;
}