本文整理汇总了PHP中push函数的典型用法代码示例。如果您正苦于以下问题:PHP push函数的具体用法?PHP push怎么用?PHP push使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了push函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: validateAndSave
/**
* Validate inputs and save to database.
*
* @return Response
*/
protected function validateAndSave($post)
{
$validator = Validator::make(Input::all(), Post::$rules);
if ($validator->fails()) {
Session::flash('errorMessage', 'Validation failed');
return Redirect::back()->withInput()->withErrors($validator);
} else {
$post->title = Input::get('title');
$post->content = Input::get('content');
$post->user_id = Auth::id();
$image = Input::file('image');
if ($image) {
$filename = $image->getClientOriginalName();
$post->image = '/uploaded/' . $filename;
$image->move('uploaded/', $filename);
}
$result = $post->save();
$posttags = Input::has('tuttags') ? Input::get('tuttags') : array();
if (Input::has('addtags')) {
$addtag = Input::get('addtags');
$posttags . push($addtag);
}
$post->tags()->sync($posttags);
$post->save();
if ($result) {
Session::flash('successMessage', 'Great Success!');
return Redirect::action('PostsController@show', $post->slug);
} else {
Session::flash('errorMessage', 'Post was not saved.');
return Redirect::back()->withInput();
}
}
}
开发者ID:mkwarren21,项目名称:blog.dev,代码行数:38,代码来源:PostsController.php
示例2: __invoke
public function __invoke()
{
$today = $this->getDateInThePast(0);
$oneWeekAgo = $this->getDateInThePast(7);
$twoWeeksAgo = $this->getDateInThePast(14);
$threeWeeksAgo = $this->getDateInThePast(21);
$service = $this->adwords->getService('AdGroupService');
$selector = new \Selector();
$selector->predicates = [new \Predicate('Status', 'EQUALS', 'ENABLED'), new \Predicate('CampaignStatus', 'EQUALS', 'ENABLED')];
$selector->orderBy = new \OrderBy('ctr', 'ASCENDING');
$selector->paging = new \Paging(0, \AdWordsConstants::RECOMMENDED_PAGE_SIZE);
do {
$page = $service->get($selector);
if (is_array($page->entries)) {
foreach ($page->entries as $adGroup) {
// Let's look at the trend of the ad group's CTR.
$statsThreeWeeksAgo = $this->getStatsFor($adGroup, $threeWeeksAgo, $twoWeeksAgo);
$statsTwoWeeksAgo = $this->getStatsFor($adGroup, $twoWeeksAgo, $oneWeekAgo);
$statsLastWeek = $this->getStatsFor($adGroup, $oneWeekAgo, $today);
// Week over week, the ad group is declining - record that!
if ($statsLastWeek->getCtr() < $statsTwoWeeksAgo->getCtr() && $statsTwoWeeksAgo->getCtr() < $statsThreeWeeksAgo->getCtr()) {
reportRows . push([adGroup . getCampaign() . getName(), adGroup . getName(), statsLastWeek . getCtr() * 100, statsLastWeek . getCost(), statsTwoWeeksAgo . getCtr() * 100, statsTwoWeeksAgo . getCost(), statsThreeWeeksAgo . getCtr() * 100, statsThreeWeeksAgo . getCost()]);
}
}
}
$selector->paging->startIndex += $selector->paging->numberResults;
} while (!is_null($page->entries));
}
开发者ID:bashilbers,项目名称:AdWordsApiScripts,代码行数:28,代码来源:DecliningAdGroups.php
示例3: addSnippet
public function addSnippet(Tx_T3tt_Domain_Model_XsltSnippet $snippetFile)
{
if (strlen($snippetFile->getContent()) > 0) {
$this->_snippets . push($snippetFile);
} else {
throw new Tx_T3tt_Domain_Model_Exception_InvalidParamsException("Snippet `" . $snippetFile . "' is empty.");
}
}
开发者ID:nforgerit,项目名称:TYPO3-Transition-Tool,代码行数:8,代码来源:StylesheetAggregation.php
示例4: addProductToList
public function addProductToList($productReference, $active)
{
//var result = file_put_contents($this->productListFile, $productReference, FILE_APPEND | LOCK_EX);
if ($active === TRUE) {
$this->activeProducts . push($productReference);
} else {
$this->notActiveProducts . push($productReference);
}
}
开发者ID:valucifer,项目名称:S-SoldP-Pal,代码行数:9,代码来源:ProductWithoutImageList.php
示例5: response_to_POST
function response_to_POST()
{
if ($_POST) {
// if data was sent
push($GLOBALS['db'], $_POST);
$_SESSION['db'] = $GLOBALS['db'];
// save to session (to be avaliable on the next request)
}
echo '{"comments": ' . json_encode($GLOBALS['db']) . '}';
}
开发者ID:vitorg,项目名称:ReactJS,代码行数:10,代码来源:server.php
示例6: addKey
private function addKey($key)
{
push($this->keys, $key);
$connection = ssh2_connect($this->server->ip);
$rC = 0;
do {
//ssh2_exec($connection, "echo #$key->contact@$this->server >> $this->home/.ssh/authorized_keys");
//ssh2_exec($connection, "echo $key->pubKey >> $this->home/.ssh/authorized_keys");
sleep(1);
$rC++;
} while (!$stream && $rC < 3);
}
开发者ID:juckerf,项目名称:sshAkD,代码行数:12,代码来源:User.php
示例7: signForRequestToken
/**
* Sign the request when requesting a request token
* @param $curl
* @param $urlCallback
* @param $signatureMethod
*/
public function signForRequestToken($curl, $urlCallback, $signatureMethod = null)
{
if( $signatureMethod === null)
{
$signatureMethod = new \Zeflasher\OAuth\SignatureMethods\OAuthSignatureMethodHmacSha1();
}
$oauthParameters = new \Zeflasher\OAuth\Client\OAuthParameters($this->_consumerKey, $signatureMethod);
$oauthParameters->addParameters(urlRequest.data);
$oauthParameters->addParameters(_getGETParameters(urlRequest));
$oauthParameters->add(OAuthConstants.CALLBACK, urlCallback);
$signature = getSignature(urlRequest, oauthParameters, OAuthConstants.EMPTY_TOKEN_SECRET, signatureMethod);
$oauthParameters->add(\Zeflasher\OAuth\OAuthConstants::OAUTH_CLIENT_SIGNATURE, $signature);
//
$headerString = $oauthParameters->getAuthorizationHeaderValue();
urlRequest.requestHeaders.push(\Zeflasher\OAuth\OAuthConstants::OAUTH_CLIENT_HEADER, $headerString);
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:24,代码来源:OauthSigner.php
示例8: getUsers
private function getUsers($connection)
{
/* get users with dir in /home/. try three times (with 1sec pause) --> planned to make an extra method somewhere else for this */
$rC = 0;
do {
$stream = ssh2_exec($connection, 'cat /etc/passwd | grep "/home" |cut -d: -f1,6');
sleep(1);
$rC++;
} while (!$stream && $rC < 3);
/* split the output by newline */
$usersHomes = preg_split('/$\\R?^/m', stream_get_contents($stream));
/* make a new user for every line and add it to the $users-array */
foreach ($usersHomes as $uH) {
$userAttrs = array(explode(':', $uH));
push($this->users, new User($userAttrs[0], $userAttrs[1], $this->name));
}
/* if adminUser is root add it to the array too ('cause he'd not be catched by the "grep /home" below */
if ($this->adminUser->name == "root") {
push($this->users, new User("root", "/root/", $this->name));
}
}
开发者ID:juckerf,项目名称:sshAkD,代码行数:21,代码来源:Server.php
示例9: inp
function inp($columnid, $arrayOFchisla, $n)
{
$massiv = array();
$res;
$IDc;
$massiv . push(columnid);
$res = 1;
$IDc = columnid - 1;
while (IDc != 0) {
$massiv . push(IDc);
$res = res + 1;
$IDc--;
}
$IDc = columnid + 1;
while (IDc != 0) {
$massiv . push(IDc);
$res = res + 1;
$IDc++;
}
$a = array();
$a[1] = ia($massiv, $res, $arrayOFchisla, $inparr);
$a[0] = $res;
return $a;
}
开发者ID:lexasub,项目名称:shifrWithPHP,代码行数:24,代码来源:pobochnyeFunctions.php
示例10: switch
switch ($action) {
case 'pulldef':
$content = \SimpleSAML\Utils\HTTP::fetch($base . 'export.php?aid=' . $application . '&type=def&file=' . $basefile);
file_put_contents($fileWithoutExt . '.definition.json', $content);
break;
case 'pull':
try {
$content = \SimpleSAML\Utils\HTTP::fetch($base . 'export.php?aid=' . $application . '&type=translation&file=' . $basefile);
file_put_contents($fileWithoutExt . '.translation.json', $content);
} catch (SimpleSAML_Error_Exception $e) {
echo 'Translation unavailable for ' . $basefile;
SimpleSAML_Logger::warning("Translation unavailable for {$basefile} in {$base}: " . $e->getMessage());
}
break;
case 'push':
push($file, $basefile, $application, $type);
break;
case 'convert':
include $file;
$definition = json_format(convert_definition($lang));
$translation = json_format(convert_translation($lang)) . "\n";
file_put_contents($fileWithoutExt . '.definition.json', $definition);
file_put_contents($fileWithoutExt . '.translation.json', $translation);
break;
default:
throw new Exception('Unknown action [' . $action . ']');
}
function ssp_readline($prompt = '')
{
echo $prompt;
return rtrim(fgets(STDIN), "\n");
开发者ID:tractorcow,项目名称:simplesamlphp,代码行数:31,代码来源:translation.php
示例11: push
function push($m)
{
$a = func_get_args();
$f = $a[0];
if (!isIn($f, array('replace', 'byIndex', 'auto', 'distinct', 'begin'))) {
$f = 'auto';
} else {
mov_next($a);
}
while (list($i, $v) = each($a)) {
push($this->O, $f, $v);
}
return $this;
}
开发者ID:hoangsoft90,项目名称:hw-sudoku-wordpress,代码行数:14,代码来源:hphp.php
示例12: __invoke
public function __invoke()
{
$this->createLabel();
$alert_text = [];
$history = [];
$currentTime = new \DateTime();
$today = $currentTime->format('m') + 1 + "/" + $currentTime . getDate() + "/" + $currentTime->format('Y');
$keywordIterator;
$line_counter = 0;
while ($keywordIterator->hasNext()) {
$keyword = keywordIterator . next();
$line_counter++;
$current_quality_score = $keyword->qualityScore;
$keywordLabelsIterator = keyword . labels() . withCondition("Name STARTS_WITH 'QS: '") . get();
if ($keywordLabelsIterator->hasNext()) {
$keyword_label = $keywordLabelsIterator . next();
$matches = new RegExp('QS: ([0-9]+)$') . exec($keyword_label . getName());
$old_quality_score = $matches[1];
} else {
$old_quality_score = 0;
}
// For the history also note the change or whether this keyword is new
if ($old_quality_score > 0) {
$change = $current_quality_score - $old_quality_score;
} else {
$change = "NEW";
}
$row = [$today, $keyword . getCampaign() . getName(), $keyword . getAdGroup() . getName(), $keyword . getText(), $current_quality_score, $change];
$history . push(row);
// If there is a previously tracked quality score and it's different from the current one...
if ($old_quality_score > 0 && $current_quality_score != $old_quality_score) {
// Make a note of this to log it and possibly send it via email later
$alert_text . push($current_quality_score + "\t" + $old_quality_score + "\t" + $change + "\t" + $keyword . getText());
// Remove the old label
$keyword . removeLabel($keyword_label . getName());
}
// Store the current QS for the next time by using a label
$keyword . applyLabel("QS: " + $current_quality_score);
}
if ($line_counter == 0) {
$this->logger->log("Couldn't find any keywords marked for quality score tracking. To mark keywords for tracking, apply the label '" + $label_name + "' to those keywords.");
return;
}
$this->logger->log("Tracked " + $line_counter + " keyword quality scores. To select different keywords for tracking, apply the label '" + $label_name + "' to those keywords.");
// Store history
$history_sheet = spreadsheet . getSheetByName('QS history');
$history_sheet . getRange($history_sheet . getLastRow() + 1, 1, $history . length, 6) . setValues($history);
// If there are notes for alerts then prepare a message to log and possibly send via email
if ($alert_text . length) {
$message = "The following quality score changes were discovered:\nNew\tOld\tChange\tKeyword\n";
for ($i = 0; $i < count($alert_text); $i++) {
$message += $alert_text[i] + "\n";
}
// Also include a link to the spreadsheet
$message += "\n" + "The complete history is available at " + $spreadsheet . getUrl();
$this->logger->log($message);
// If there is an email address send out a notification
if ($email_address && $email_address != "YOUR_EMAIL_HERE") {
$this->mailer->sendEmail($email_address, "Quality Score Tracker: Changes detected", $message);
}
}
}
开发者ID:bashilbers,项目名称:AdWordsApiScripts,代码行数:62,代码来源:TrackQualityScore.php
示例13: die
default:
die('Error: Invalid cause!');
}
$time = time();
$response = 0;
$message = htmlentities($_POST['text']);
$db = new PDO($dbpdodsn, $dbuser, $dbpassword, array(PDO::ATTR_EMULATE_PREPARES => false, PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$st_addcall = $db->prepare('INSERT INTO calls (callid, deviceid, type, time, response, message, reminded) VALUES (:cid, :did, :ty, :ti, :re, :m, 0)');
$st_addcall->bindParam(':cid', $callid);
$st_addcall->bindParam(':did', $deviceid);
$st_addcall->bindParam(':ty', $type);
$st_addcall->bindParam(':ti', $time);
$st_addcall->bindParam(':re', $response);
$st_addcall->bindParam(':m', $message);
$st_addcall->execute();
push($deviceid, $callid, $type, $time, $message, false);
header('Location: wait.php?callid=' . $callid);
die('Redirecting...');
}
pageheader(0, "Choosing cause");
?>
<p>Enter the cause by pressing the corresponding button. If you want to add text (optional), enter your message before pressing the button.</p>
<form method="post">
<button class="submitbutton" type="submit" name="cause" value="1">Food</button>
<button class="submitbutton" type="submit" name="cause" value="2">IT help</button>
<!-- TODO: Better translation. -->
<button class="submitbutton" type="submit" name="cause" value="3">Contact gewenst</button>
<p class="title">Extra tekst (Optioneel)</p>
<input type="text" name="text">
</form>
<?php
开发者ID:TomWis97,项目名称:CallTom,代码行数:31,代码来源:new.php
示例14: getParts
public function getParts($vehicleID = 0, $mount = "", $year = "", $make = "", $model = "", $style = "")
{
$req = "";
if ($vehicleID > 0) {
$req = $this->config->getDomain() . "GetParts";
$req .= "&dataType=" . $this->config->getDataType();
} else {
}
$resp = $this->helper->curlGet($req);
$part_arr = array();
foreach (json_decode($resp) as $part) {
$part_arr . push($part);
}
return $part_arr;
}
开发者ID:ninnemana,项目名称:CURT-Happpi,代码行数:15,代码来源:Vehicle.php
示例15: parser_performAction
function parser_performAction(&$thisS, $yytext, $yyleng, $yylineno, $yystate, $S, $_S, $O)
{
switch ($yystate) {
case 1:
return $S[$O - 1];
break;
case 2:
return [['']];
break;
case 3:
$thisS = [$S[$O]];
break;
case 4:
$thisS = [];
break;
case 5:
$thisS = [''];
break;
case 6:
$thisS = $S[$O - 1];
break;
case 7:
$S[$O - 1][$S[$O - 1] . length - 1] . push('');
$thisS = $S[$O - 1];
break;
case 8:
$S[$O - 2] . push($S[$O]);
$thisS = $S[$O - 2];
break;
case 9:
$S[$O - 2][$S[$O - 2] . length - 1] . push('');
$S[$O - 2] . push($S[$O]);
$thisS = $S[$O - 2];
break;
case 10:
$thisS = [$S[$O]];
break;
case 11:
$thisS = $S[$O - 1];
break;
case 12:
$thisS = [''];
break;
case 13:
//$thisS = [];
break;
case 14:
$S[$O - 1] . push('');
$thisS = $S[$O - 1];
break;
case 15:
//$S[$O-1].push('');
$thisS = $S[$O - 1];
break;
case 16:
$S[$O - 2] . push('');
$S[$O - 2] . push($S[$O]);
$thisS = $S[$O - 2];
break;
case 17:
//$S[$O-2].push('');
$S[$O - 2] . push($S[$O]);
$thisS = $S[$O - 2];
break;
case 18:
$thisS = '';
break;
case 19:
$thisS = $S[$O - 1];
break;
case 15:
$thisS = $S[$O];
break;
case 20:
$thisS = $S[$O - 1] + '' + $S[$O];
break;
}
}
开发者ID:gokhanbhs,项目名称:jquerysheet,代码行数:78,代码来源:tsv.php
示例16: foreach
<?php
require_once 'stack.php';
/**
* one card
* [
* 'color' => 'pika',
* 'value' => 'D'
* ]
*/
foreach (['clubs', 'diamonds', 'hearts', 'spades'] as $color) {
foreach (array_merge(range(2, 10), ['J', 'D', 'K', 'A']) as $value) {
push(['color' => $color, 'value' => $value]);
}
}
shuffle($stack);
$cardsToGive = 12;
while ($cardsToGive--) {
pop();
}
$trump = pop();
print_r($trump);
开发者ID:gpichurov,项目名称:ittalents_season5,代码行数:22,代码来源:santase.php
示例17: pop
<?php
/**
* Created by PhpStorm.
* User: just
* Date: 24.11.15
* Time: 09:27
*/
$stack = [];
function pop()
{
global $stack;
return array_pop($stack);
}
function push($entry)
{
global $stack;
return array_push($stack, $entry);
}
foreach (['clubs', 'diamonds', 'hearts', 'spades'] as $color) {
foreach (array_merge(range(2, 10), ['J', 'D', 'K', 'A']) as $value) {
push(['Color' => $color, 'Value' => $value]);
}
}
shuffle($stack);
$cardToGive = 12;
while ($cardToGive -= 1) {
pop();
}
$trump = pop();
print_r($trump);
开发者ID:Just-Man,项目名称:PHP,代码行数:31,代码来源:Stack.php
示例18: getStudents
function getStudents($courseid)
{
$conn = new mysqli("localhost", "root", "admin", "moodledb");
if ($conn->connect_errno) {
echo "failed to connect to mysql:(" . $conn->connect_errno . ") " . $mysql->connect_error;
}
$code = "select " . "ue.userid " . "from " . "mdl_user_enrolments ue, mdl_enrol e " . "where " . "e.roleid = 5 and ue.enrolid = e.id " . "and e.courseid=Y;";
$resp = $conn->query($code);
$users = array();
while ($row = $resp->fetch_assoc()) {
$users . push($row['userid']);
}
print_r($users);
}
开发者ID:steffanboodhoo,项目名称:mdl_report,代码行数:14,代码来源:db.php
示例19: push_notification
/**
* Push notification
*/
public function push_notification()
{
if ($this->isAjax()) {
$id = isset($_POST['id']) ? intval($_POST['id']) : $this->redirect('/');
$vip_only = isset($_POST['vip_only']) ? intval($_POST['vip_only']) : $this->redirect('/');
$flag = false;
$message = M('Notification')->field(array('content'))->where(array('id' => $id))->find();
if ($vip_only) {
$result = M('Member')->field(array('id'))->where(array('is_vip' => 1))->select();
$vips = array();
if (!empty($result)) {
$i = ceil(count($result) / 1000);
for ($j = 1; $j <= $i; $j++) {
$alias = "";
$length = min(array($j * 1000, count($result)));
for ($k = ($j - 1) * 1000; $k < $length; $k++) {
$alias .= $result[$k]['id'] . ",";
}
$vips[] = rtrim($alias, ",");
}
}
if ($vips) {
for ($i = 0; $i < count($vips); $i++) {
if (push($message['content'], 3, $vips[$i])) {
$flag = true;
} else {
break;
}
}
}
} else {
$flag = push($message['content']);
}
if ($flag) {
// Update the notification status to is pushed.
M('Notification')->where(array('id' => $id))->save(array('is_pushed' => 1));
$this->ajaxReturn(array('status' => true, 'msg' => 'Push notificatio successful'));
} else {
$this->ajaxReturn(array('status' => false, 'msg' => 'Push notificatio failed,please try again later'));
}
} else {
$this->redirect('/');
}
}
开发者ID:leamiko,项目名称:project_2,代码行数:47,代码来源:SettingAction.class.php
示例20: DNUI_delete
/**
* Delete all image given the array ids
* @param type $imagesToDelete
* @param type $options
* @return array
*/
function DNUI_delete($imagesToDelete, $options)
{
$updateInServer = $options['updateInServer'];
$backup = $options["backup"];
$base = wp_upload_dir();
$base = $base['basedir'];
$errors = array();
$basePlugin = plugin_dir_path(__FILE__) . '../backup/';
foreach ($imagesToDelete as $key => $imageToDelete) {
clearstatcache();
$image = wp_get_attachment_metadata($imageToDelete["id"]);
$tmp = explode("/", $image["file"]);
$imageName = array_pop($tmp);
$folder = implode("/", $tmp);
$dirBase = $base . '/' . $folder . '/';
if ($backup) {
$dirBackup = $basePlugin . '/' . $imageToDelete["id"];
$backupExist = file_exists($dirBackup . '/' . $imageToDelete["id"] . '.backup');
if (!$backupExist) {
$backupInfo = array();
$backupInfo["dirBase"] = $dirBase;
$backupInfo["posts"] = DNUI_getRowPost($imageToDelete["id"]);
$backupInfo["postMeta"] = DNUI_getRowPostMeta($imageToDelete["id"]);
if (!file_exists($dirBackup)) {
mkdir($dirBackup, 0755, true);
}
}
}
if ($imageToDelete["toDelete"][0] == "original") {
if ($backup) {
$dirImage = $dirBase . $imageName;
DNUI_copy($dirImage, $dirBackup . '/' . $imageName);
foreach ($image["sizes"] as $size => $imageSize) {
$dirImage = $dirBase . $imageSize["file"];
DNUI_copy($dirImage, $dirBackup . '/' . $imageSize["file"]);
}
}
wp_delete_attachment($imageToDelete["id"]);
} else {
foreach ($imageToDelete["toDelete"] as $keyS => $imageS) {
$size = $image["sizes"][$imageS];
clearstatcache();
$dirImage = $dirBase . $size["file"];
if (!empty($size)) {
if (!file_exists($dirImage)) {
if ($updateInServer) {
unset($image["sizes"][$imageS]);
}
} else {
if ($backup) {
DNUI_copy($dirImage, $dirBackup . '/' . $size["file"]);
}
if (@unlink($dirImage)) {
unset($image["sizes"][$imageS]);
} else {
$errors . push('Problem with ' . $size["file"] . " try toe active the option for delete the image if not exist");
}
}
}
wp_update_attachment_metadata($imageToDelete["id"], $image);
}
}
if ($backup) {
if (!$backupExist) {
file_put_contents($dirBackup . '/' . $imageToDelete["id"] . '.backup', serialize($backupInfo));
}
}
}
return $errors;
}
开发者ID:Wikipraca,项目名称:Wikipraca-WikiSquare,代码行数:76,代码来源:dnuiL.php
注:本文中的push函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论