本文整理汇总了PHP中array_values函数的典型用法代码示例。如果您正苦于以下问题:PHP array_values函数的具体用法?PHP array_values怎么用?PHP array_values使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_values函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructs a book dialog
* $action - GET or POST action to take.
* $inclusions - NULL (in which case it does nothing), or an array of book IDs to include.
* $exclusions - NULL (in which case it does nothing), or an array of book IDs to exclude.
*/
public function __construct($header, $info_top, $info_bottom, $action, $inclusions, $exclusions)
{
$this->view = new Assets_View(__FILE__);
$caller = $_SERVER["PHP_SELF"] . "?" . http_build_query(array());
$this->view->view->caller = $caller;
$this->view->view->header = $header;
$this->view->view->info_top = $info_top;
$this->view->view->info_bottom = $info_bottom;
$this->view->view->action = $action;
$database_books = Database_Books::getInstance();
$book_ids = $database_books->getIDs();
if (is_array($inclusions)) {
$book_ids = $inclusions;
}
if (is_array($exclusions)) {
$book_ids = array_diff($book_ids, $exclusions);
$book_ids = array_values($book_ids);
}
foreach ($book_ids as $id) {
$book_names[] = $database_books->getEnglishFromId($id);
}
$this->view->view->book_ids = $book_ids;
$this->view->view->book_names = $book_names;
$this->view->render("books2.php");
Assets_Page::footer();
die;
}
示例2: block
/**
* Formats a message as a block of text.
*
* @param string|array $messages The message to write in the block
* @param string|null $type The block type (added in [] on first line)
* @param string|null $style The style to apply to the whole block
* @param string $prefix The prefix for the block
* @param bool $padding Whether to add vertical padding
*/
public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
{
$this->autoPrependBlock();
$messages = is_array($messages) ? array_values($messages) : array($messages);
$lines = array();
// add type
if (null !== $type) {
$messages[0] = sprintf('[%s] %s', $type, $messages[0]);
}
// wrap and add newlines for each element
foreach ($messages as $key => $message) {
$message = OutputFormatter::escape($message);
$lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - Helper::strlen($prefix), PHP_EOL, true)));
if (count($messages) > 1 && $key < count($messages) - 1) {
$lines[] = '';
}
}
if ($padding && $this->isDecorated()) {
array_unshift($lines, '');
$lines[] = '';
}
foreach ($lines as &$line) {
$line = sprintf('%s%s', $prefix, $line);
$line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
if ($style) {
$line = sprintf('<%s>%s</>', $style, $line);
}
}
$this->writeln($lines);
$this->newLine();
}
示例3: numeric_variable
/**
* Checks whether a string is a valid number with optional prefix ~, + or -.
* Allow only EN . delimiter
*
* @param string $str input string
* @return boolean
*/
public static function numeric_variable($str)
{
// Get the decimal point for the current locale
list($decimal) = array_values(localeconv());
// A lookahead is used to make sure the string contains at least one digit (before or after the decimal point)
return (bool) preg_match('/^[~\\+-]?\\d*\\.?\\d*$/', (string) $str);
}
示例4: index
/**
* Display a listing of the resource.
*
* @param Store $store
*
* @return Response
*/
public function index(Store $store)
{
// ImportedProduct::truncate();
// ErrorProduct::truncate();
JavaScript::put(['url' => '/products', 'os_total' => OsProduct::count(), 'imported_total' => ImportedProduct::count(), 'resource' => array_values(array_diff(OsProduct::orderBy('products_id', 'desc')->lists('products_id')->toArray(), ImportedProduct::orderBy('os_id', 'desc')->lists('os_id')->toArray(), ErrorProduct::orderBy('os_id', 'desc')->lists('os_id')->toArray()))]);
return view('importer.index', ['resource' => 'Products']);
}
示例5: _prepareColumns
protected function _prepareColumns()
{
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager_Type_Relation_Parent $parentType */
$parentType = $this->getListingProduct()->getChildObject()->getVariationManager()->getTypeModel();
$channelAttributesSets = $parentType->getChannelAttributesSets();
$productAttributes = $parentType->getProductAttributes();
if ($parentType->hasMatchedAttributes()) {
$productAttributes = array_keys($parentType->getMatchedAttributes());
$channelAttributes = array_values($parentType->getMatchedAttributes());
} else {
if (!empty($channelAttributesSets)) {
$channelAttributes = array_keys($channelAttributesSets);
} else {
$channelAttributes = array();
}
}
$this->addColumn('product_options', array('header' => Mage::helper('M2ePro')->__('Magento Variation'), 'align' => 'left', 'width' => '210px', 'sortable' => false, 'index' => 'additional_data', 'filter_index' => 'additional_data', 'frame_callback' => array($this, 'callbackColumnProductOptions'), 'filter' => 'M2ePro/adminhtml_grid_column_filter_attributesOptions', 'options' => $productAttributes, 'filter_condition_callback' => array($this, 'callbackProductOptions')));
$this->addColumn('channel_options', array('header' => Mage::helper('M2ePro')->__('Amazon Variation'), 'align' => 'left', 'width' => '210px', 'sortable' => false, 'index' => 'additional_data', 'filter_index' => 'additional_data', 'frame_callback' => array($this, 'callbackColumnChannelOptions'), 'filter' => 'M2ePro/adminhtml_grid_column_filter_attributesOptions', 'options' => $channelAttributes, 'filter_condition_callback' => array($this, 'callbackChannelOptions')));
$this->addColumn('sku', array('header' => Mage::helper('M2ePro')->__('SKU'), 'align' => 'left', 'type' => 'text', 'index' => 'sku', 'filter_index' => 'sku', 'frame_callback' => array($this, 'callbackColumnAmazonSku')));
$this->addColumn('general_id', array('header' => Mage::helper('M2ePro')->__('ASIN / ISBN'), 'align' => 'left', 'width' => '100px', 'type' => 'text', 'index' => 'general_id', 'filter_index' => 'general_id', 'frame_callback' => array($this, 'callbackColumnGeneralId')));
$this->addColumn('online_qty', array('header' => Mage::helper('M2ePro')->__('QTY'), 'align' => 'right', 'width' => '70px', 'type' => 'number', 'index' => 'online_qty', 'filter_index' => 'online_qty', 'frame_callback' => array($this, 'callbackColumnAvailableQty'), 'filter' => 'M2ePro/adminhtml_common_amazon_grid_column_filter_qty', 'filter_condition_callback' => array($this, 'callbackFilterQty')));
$this->addColumn('online_price', array('header' => Mage::helper('M2ePro')->__('Price'), 'align' => 'right', 'width' => '70px', 'type' => 'number', 'index' => 'online_price', 'filter_index' => 'online_price', 'frame_callback' => array($this, 'callbackColumnPrice'), 'filter_condition_callback' => array($this, 'callbackFilterPrice')));
$this->addColumn('status', array('header' => Mage::helper('M2ePro')->__('Status'), 'width' => '100px', 'index' => 'status', 'filter_index' => 'status', 'type' => 'options', 'sortable' => false, 'options' => array(Ess_M2ePro_Model_Listing_Product::STATUS_UNKNOWN => Mage::helper('M2ePro')->__('Unknown'), Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'), Ess_M2ePro_Model_Listing_Product::STATUS_LISTED => Mage::helper('M2ePro')->__('Active'), Ess_M2ePro_Model_Listing_Product::STATUS_STOPPED => Mage::helper('M2ePro')->__('Inactive'), Ess_M2ePro_Model_Listing_Product::STATUS_BLOCKED => Mage::helper('M2ePro')->__('Inactive (Blocked)')), 'frame_callback' => array($this, 'callbackColumnStatus')));
return parent::_prepareColumns();
}
示例6: find
/**
* {@inheritdoc}
*/
public function find($ip, $url, $limit, $method)
{
$file = $this->getIndexFilename();
if (!file_exists($file)) {
return array();
}
$file = fopen($file, 'r');
fseek($file, 0, SEEK_END);
$result = array();
while ($limit > 0) {
$line = $this->readLineFromFile($file);
if (false === $line) {
break;
}
if ($line === '') {
continue;
}
list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line);
if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) {
continue;
}
$result[$csvToken] = array('token' => $csvToken, 'ip' => $csvIp, 'method' => $csvMethod, 'url' => $csvUrl, 'time' => $csvTime, 'parent' => $csvParent);
--$limit;
}
fclose($file);
return array_values($result);
}
示例7: getExportableValues
/**
* Get the default exportable values
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param array $return_value the current return value
* @param array $params supplied params
*
* @return void|array
*/
public static function getExportableValues($hook, $type, $return_value, $params)
{
if (empty($params) || !is_array($params)) {
return;
}
$content_type = elgg_extract('type', $params);
$readable = (bool) elgg_extract('readable', $params, false);
// default exportable values
$defaults = [elgg_echo('csv_exporter:exportable_value:owner_name') => 'csv_exporter_owner_name', elgg_echo('csv_exporter:exportable_value:owner_username') => 'csv_exporter_owner_username', elgg_echo('csv_exporter:exportable_value:owner_email') => 'csv_exporter_owner_email', elgg_echo('csv_exporter:exportable_value:owner_url') => 'csv_exporter_owner_url', elgg_echo('csv_exporter:exportable_value:container_name') => 'csv_exporter_container_name', elgg_echo('csv_exporter:exportable_value:container_username') => 'csv_exporter_container_username', elgg_echo('csv_exporter:exportable_value:container_email') => 'csv_exporter_container_email', elgg_echo('csv_exporter:exportable_value:container_url') => 'csv_exporter_container_url', elgg_echo('csv_exporter:exportable_value:time_created_readable') => 'csv_exporter_time_created_readable', elgg_echo('csv_exporter:exportable_value:time_updated_readable') => 'csv_exporter_time_updated_readable', elgg_echo('csv_exporter:exportable_value:url') => 'csv_exporter_url'];
$content_fields = [];
switch ($content_type) {
case 'object':
$content_fields = self::getObjectExportableValues();
break;
case 'user':
$content_fields = self::getUserExportableValues();
break;
case 'group':
$content_fields = self::getGroupExportableValues();
break;
}
// combine default and type fields
$fields = array_merge($defaults, $content_fields);
// which version did we want
if (!$readable) {
$fields = array_values($fields);
}
return array_merge($return_value, $fields);
}
示例8: UserModel_BeforeSaveSerialized_Handler
/**
* Save Email.Flag preference list in config for easier access.
*/
public function UserModel_BeforeSaveSerialized_Handler($Sender)
{
if (Gdn::Session()->CheckPermission('Plugins.Flagging.Notify')) {
if ($Sender->EventArguments['Column'] == 'Preferences' && is_array($Sender->EventArguments['Name'])) {
// Shorten our arguments
$UserID = $Sender->EventArguments['UserID'];
$Prefs = $Sender->EventArguments['Name'];
$FlagPref = GetValue('Email.Flag', $Prefs, NULL);
if ($FlagPref !== NULL) {
// Add or remove user from config array
$NotifyUsers = C('Plugins.Flagging.NotifyUsers', array());
$IsNotified = array_search($UserID, $NotifyUsers);
// beware '0' key
if ($IsNotified !== FALSE && !$FlagPref) {
// Remove from NotifyUsers
unset($NotifyUsers[$IsNotified]);
} elseif ($IsNotified === FALSE && $FlagPref) {
// Add to NotifyUsers
$NotifyUsers[] = $UserID;
}
// Save new list of users to notify
SaveToConfig('Plugins.Flagging.NotifyUsers', array_values($NotifyUsers));
}
}
}
}
示例9: curl_setopt_array
function curl_setopt_array($handle, array $options)
{
if (array_values($options) != [null, null, null, null]) {
$_SERVER['last_curl'] = $options;
}
\curl_setopt_array($handle, $options);
}
示例10: create
/**
* The model method will be override in deifferent way between different import way
*
* @param \App\Utility\Chinghwa\Flap\POS_Member\Import\ImportHandler\Lyin\Adapter $adapter
* @return PosMemberImportContent $model
*/
public function create($adapter)
{
$dataHolder = $adapter->getDataHolder();
$memberData = $this->fetchExistOrEmpty($dataHolder);
list($serNo, $code, $serNoI) = NULL !== $memberData ? array_values($memberData) : NULL;
$model = new PosMemberImportContent();
$model->serno = $serNo;
$model->code = $code;
$model->sernoi = $serNoI;
$model->name = DataHolder::getByProxy($dataHolder->getName());
$model->email = DataHolder::getByProxy($dataHolder->getEmail());
$model->cellphone = DataHolder::getByProxy($dataHolder->getCellphone());
$model->hometel = DataHolder::getByProxy($dataHolder->getHometel());
$model->officetel = DataHolder::getByProxy($dataHolder->getOfficetel());
$model->birthday = DataHolder::getByProxy($dataHolder->getBirthday());
$model->homeaddress = DataHolder::getByProxy($dataHolder->getAddress());
$model->hospital = DataHolder::getByProxy($dataHolder->getHospital());
$model->state_id = $this->_getStateId($dataHolder);
$model->distinction = $adapter->getOptions()[Import::OPTIONS_DISTINCTION];
$model->category = $adapter->getOptions()[Import::OPTIONS_CATEGORY];
$model->pos_member_import_task_id = $adapter->getOptions()[Import::OPTIONS_TASK]->id;
$model->period_at = $this->_getPeriodAt($dataHolder);
$model->sex = Import::FEMALE_SEX_TEXT;
$model->flags = $model->getFlags();
$model->memo = $model->genMemo();
$model->is_exist = !empty($serNo);
$model->fixStatus();
return $model;
}
示例11: __toString
public function __toString()
{
$this->_config->setXType('');
$this->_config->setFType('filters');
$this->_config->filters = "[\n\t" . Utils_String::addIndent(implode(",\n", array_values($this->_filters)), 2) . "\n]";
return parent::__toString();
}
示例12: process_notifications
public function process_notifications($args)
{
$enabled_handlers = $this->get_enabled_handlers();
// if we can't find any enabled event handlers, bail.
if (empty($enabled_handlers)) {
return;
}
// calculate if this type event is set in the rules
$options = AAL_Main::instance()->settings->get_options();
// if there are no rules set, bail.
if (empty($options['notification_rules']) || !is_array($options['notification_rules'])) {
return;
}
$notification_matched_rules = array();
// loop through the set of rules, and figure out if this current action meets a set rule
foreach ($options['notification_rules'] as $notification_rule) {
list($n_key, $n_condition, $n_value) = array_values($notification_rule);
switch ($n_key) {
case 'action-type':
if ($n_value == $args['object_type']) {
$notification_matched_rules[] = $notification_rule;
}
break;
}
}
// did we find any matches? if not, let's pretend as if nothing has happened here ;)
if (!empty($notification_matched_rules)) {
// cycle through enabled handlers and trigger them
foreach ($enabled_handlers as $enabled_handler) {
$enabled_handler->trigger($args);
}
}
}
示例13: element_value
public function element_value($value = '')
{
$value = $this->value;
if (is_array($this->multilang) && is_array($value)) {
$current = $this->multilang['current'];
if (isset($value[$current])) {
$value = $value[$current];
} else {
if ($this->multilang['current'] == $this->multilang['default']) {
$value = $this->value;
} else {
$value = '';
}
}
} else {
if (!is_array($this->multilang) && isset($this->value['multilang']) && is_array($this->value)) {
$value = array_values($this->value);
$value = $value[0];
} else {
if (is_array($this->multilang) && !is_array($value) && $this->multilang['current'] != $this->multilang['default']) {
$value = '';
}
}
}
return $value;
}
示例14: replace_path_consts
private function replace_path_consts($source, $path)
{
$replacements = array('__FILE__' => "'{$path}'", '__DIR__' => "'" . dirname($path) . "'");
$old = array_keys($replacements);
$new = array_values($replacements);
return str_replace($old, $new, $source);
}
示例15: Header
function Header()
{
$this->Print_Logo();
$this->SetDrawColor(0);
$this->SetLineWidth(0);
$this->SetXY($this->margenDerecho, 10);
$this->SetFont('Arial', 'B', 16);
$this->Cell(0, 0, 'Datos de la Empresa', 0, 0, 'C');
$psiniestro = $_SESSION["ReportesSiniestros"]["ID"];
$porden = $_SESSION["ReportesSiniestros"]["ORDEN"];
$this->SetFont('Arial', "I", 6);
//$ahora = ["FECHASERVER"];
date_default_timezone_set('UTC');
$this->SetXY(5, 5);
$ahora = date("d/m/Y");
$this->Cell(0, 0, $ahora . " ", 0, 0, 'L');
$this->Ln(15);
$this->SetX($this->margenDerecho);
$this->RellenaFondoLinea(192, 192, 192);
/*
$this->SetFillColor(192, 192, 192);
$x=$this->GetX();
$y=$this->GetY();
$anchofijo = $this->w - 15;
$this->Rect($x, $y+0.2, $anchofijo, 5, "F");
$this->SetFillColor(0, 0, 0);
*/
$this->SetTextColor(0, 0, 0);
$this->SetFontAlignGeneral();
$Newrow = array_values($this->arrayTitulos);
$this->Row($Newrow);
// $this->LineaSepara();
$this->Ln(5);
}