当前位置: 首页>>代码示例>>PHP>>正文


PHP arrayValue函数代码示例

本文整理汇总了PHP中arrayValue函数的典型用法代码示例。如果您正苦于以下问题:PHP arrayValue函数的具体用法?PHP arrayValue怎么用?PHP arrayValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了arrayValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: firstThrown_returnFiveDices

 /**
  * @test
  */
 public function firstThrown_returnFiveDices()
 {
     $player = new Player();
     $result = $player->throwDices();
     assertThat($result, arrayValue());
     assertThat(count($result), is(equalTo(5)));
 }
开发者ID:cmygeHm,项目名称:KataLessons,代码行数:10,代码来源:YatzyTest.php

示例2: isRemovable

 /**
  * Is the application/plugin/theme removable?
  *
  * @param string $Type self::TYPE_APPLICATION or self::TYPE_PLUGIN or self::TYPE_THEME
  * @param string $Name
  * @return boolean
  */
 public static function isRemovable($Type, $Name)
 {
     switch ($Type) {
         case self::TYPE_APPLICATION:
             $ApplicationManager = Gdn::Factory('ApplicationManager');
             if ($IsRemovable = !array_key_exists($Name, $ApplicationManager->EnabledApplications())) {
                 $ApplicationInfo = arrayValue($Name, $ApplicationManager->AvailableApplications(), array());
                 $ApplicationFolder = arrayValue('Folder', $ApplicationInfo, '');
                 $IsRemovable = IsWritable(PATH_APPLICATIONS . DS . $ApplicationFolder);
             }
             break;
         case self::TYPE_PLUGIN:
             if ($IsRemovable = !array_key_exists($Name, Gdn::pluginManager()->EnabledPlugins())) {
                 $PluginInfo = arrayValue($Name, Gdn::pluginManager()->AvailablePlugins(), false);
                 $PluginFolder = arrayValue('Folder', $PluginInfo, false);
                 $IsRemovable = IsWritable(PATH_PLUGINS . DS . $PluginFolder);
             }
             break;
         case self::TYPE_THEME:
             // TODO
             $IsRemovable = false;
             break;
     }
     return $IsRemovable;
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:32,代码来源:class.settingsmodule.php

示例3: testAccessorForCredentialsConvertsStringIntoArray

 public function testAccessorForCredentialsConvertsStringIntoArray()
 {
     $user = Factory::create('User', ['id' => 1]);
     $credentialsNotAccessed = $user->getAttributes()['credentials'];
     $credentialsAccessed = $user->credentials;
     assertThat($credentialsNotAccessed, is(stringValue()));
     assertThat($credentialsAccessed, is(arrayValue()));
 }
开发者ID:estebanmatias92,项目名称:pull-automatically-galleries,代码行数:8,代码来源:UserTest.php

示例4: config

 /**
  * Update the configuration.
  *
  * @return void
  */
 protected function config()
 {
     saveToConfig('Garden.Cookie.Salt', RandomString(10));
     $ApplicationInfo = [];
     include CombinePaths([PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'about.php']);
     // Detect Internet connection for CDNs
     $Disconnected = !(bool) @fsockopen('ajax.googleapis.com', 80);
     saveToConfig(['Garden.Version' => arrayValue('Version', val('Dashboard', $ApplicationInfo, []), 'Undefined'), 'Garden.Cdns.Disable' => $Disconnected, 'Garden.CanProcessImages' => function_exists('gd_info'), 'EnabledPlugins.HtmLawed' => 'HtmLawed']);
 }
开发者ID:TFidryForks,项目名称:spira,代码行数:14,代码来源:VanillaConfigurator.php

示例5: getVisitIp

function getVisitIp()
{
    $matchIp = '/^([0-9]{1,3}\\.){3}[0-9]{1,3}$/';
    $ipKeys = array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP', 'HTTP_CF_CONNECTING_IP');
    foreach ($ipKeys as $ipKey) {
        if (isset($_SERVER[$ipKey]) && preg_match($matchIp, $_SERVER[$ipKey])) {
            return $_SERVER[$ipKey];
        }
    }
    return arrayValue($_SERVER, 'REMOTE_ADDR');
}
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:11,代码来源:piwik.php

示例6: __construct

 /**
  * Constructor
  *
  * @param array $connectionData Connection Data parsed by parse_url()
  * @return self
  */
 public function __construct(array $connectionData)
 {
     if (!class_exists("Memcache", false)) {
         error("Memcache Extension not installed - Update your PHP configuration");
     }
     $this->memcache = new Memcache();
     $host = $connectionData["host"];
     $port = arrayValue($connectionData, "port");
     $port = $port ? $port : 11211;
     $connectState = $this->memcache->connect($host, $port);
     if (!$connectState) {
         error("Could not connect to Memcache Server at " . $host . ":" . $port);
     }
 }
开发者ID:nonconforme,项目名称:nreeda,代码行数:20,代码来源:Memcache.class.php

示例7: getRoute

 /**
  * Get an route that exactly matches a string.
  * @param string|int $Route The route to search for.
  * @param int $Indexed If the route is a number then it will be looked up as an index.
  *
  * @return array|bool A route or false if there is no matching route.
  */
 public function getRoute($Route, $Indexed = true)
 {
     if ($Indexed && is_numeric($Route) && $Route !== false) {
         $Keys = array_keys($this->Routes);
         $Route = arrayValue($Route, $Keys);
     }
     $Decoded = $this->_decodeRouteKey($Route);
     if ($Decoded !== false && array_key_exists($Decoded, $this->Routes)) {
         $Route = $Decoded;
     }
     if ($Route === false || !array_key_exists($Route, $this->Routes)) {
         return false;
     }
     //return $this->Routes[$Route];
     return array_merge($this->Routes[$Route], array('TypeLocale' => T($this->RouteTypes[$this->Routes[$Route]['Type']]), 'FinalDestination' => $this->Routes[$Route]['Destination']));
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:23,代码来源:class.router.php

示例8: edit

 /**
  * Edit a route.
  *
  * @since 2.0.0
  * @access public
  * @param string $RouteIndex Name of route.
  */
 public function edit($RouteIndex = false)
 {
     $this->permission('Garden.Settings.Manage');
     $this->addSideMenu('dashboard/routes');
     $this->Route = Gdn::router()->GetRoute($RouteIndex);
     $Validation = new Gdn_Validation();
     $ConfigurationModel = new Gdn_ConfigurationModel($Validation);
     $ConfigurationModel->setField(array('Route', 'Target', 'Type'));
     // Set the model on the form.
     $this->Form->setModel($ConfigurationModel);
     // If seeing the form for the first time...
     if (!$this->Form->authenticatedPostBack()) {
         // Apply the route info to the form.
         if ($this->Route !== false) {
             $this->Form->setData(array('Route' => $this->Route['Route'], 'Target' => $this->Route['Destination'], 'Type' => $this->Route['Type']));
         }
     } else {
         // Define some validation rules for the fields being saved
         $ConfigurationModel->Validation->applyRule('Route', 'Required');
         $ConfigurationModel->Validation->applyRule('Target', 'Required');
         $ConfigurationModel->Validation->applyRule('Type', 'Required');
         // Validate & Save
         $FormPostValues = $this->Form->formValues();
         // Dunno.
         if ($this->Route['Reserved']) {
             $FormPostValues['Route'] = $this->Route['Route'];
         }
         if ($ConfigurationModel->validate($FormPostValues)) {
             $NewRouteName = arrayValue('Route', $FormPostValues);
             if ($this->Route !== false && $NewRouteName != $this->Route['Route']) {
                 Gdn::router()->DeleteRoute($this->Route['Route']);
             }
             Gdn::router()->SetRoute($NewRouteName, arrayValue('Target', $FormPostValues), arrayValue('Type', $FormPostValues));
             $this->informMessage(t("The route was saved successfully."));
             $this->RedirectUrl = url('dashboard/routes');
         } else {
             $this->Form->setValidationResults($ConfigurationModel->validationResults());
         }
     }
     $this->render();
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:48,代码来源:class.routescontroller.php

示例9: comment


//.........这里部分代码省略.........
                 $this->EventArguments['Comment'] = $Comment;
                 $this->fireEvent('AfterCommentSave');
             } elseif ($CommentID === SPAM || $CommentID === UNAPPROVED) {
                 $this->StatusMessage = t('CommentRequiresApprovalStatus', 'Your comment will appear after it is approved.');
             }
             $this->Form->setValidationResults($this->CommentModel->validationResults());
             if ($CommentID > 0 && $DraftID > 0) {
                 $this->DraftModel->delete($DraftID);
             }
         }
         // Handle non-ajax requests first:
         if ($this->_DeliveryType == DELIVERY_TYPE_ALL) {
             if ($this->Form->errorCount() == 0) {
                 // Make sure that this form knows what comment we are editing.
                 if ($CommentID > 0) {
                     $this->Form->addHidden('CommentID', $CommentID);
                 }
                 // If the comment was not a draft
                 if (!$Draft) {
                     // Redirect to the new comment.
                     if ($CommentID > 0) {
                         redirect("discussion/comment/{$CommentID}/#Comment_{$CommentID}");
                     } elseif ($CommentID == SPAM) {
                         $this->setData('DiscussionUrl', DiscussionUrl($Discussion));
                         $this->View = 'Spam';
                     }
                 } elseif ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::date();
                     $this->Comment->Body = arrayValue('Body', $FormValues, '');
                     $this->Comment->Format = val('Format', $FormValues, c('Garden.InputFormatter'));
                     $this->AddAsset('Content', $this->fetchView('preview'));
                 } else {
                     // If this was a draft save, notify the user about the save
                     $this->informMessage(sprintf(t('Draft saved at %s'), Gdn_Format::date()));
                 }
             }
         } else {
             // Handle ajax-based requests
             if ($this->Form->errorCount() > 0) {
                 // Return the form errors
                 $this->ErrorMessage($this->Form->errors());
             } else {
                 // Make sure that the ajax request form knows about the newly created comment or draft id
                 $this->setJson('CommentID', $CommentID);
                 $this->setJson('DraftID', $DraftID);
                 if ($Preview) {
                     // If this was a preview click, create a comment shell with the values for this comment
                     $this->Comment = new stdClass();
                     $this->Comment->InsertUserID = $Session->User->UserID;
                     $this->Comment->InsertName = $Session->User->Name;
                     $this->Comment->InsertPhoto = $Session->User->Photo;
                     $this->Comment->DateInserted = Gdn_Format::date();
                     $this->Comment->Body = arrayValue('Body', $FormValues, '');
                     $this->View = 'preview';
                 } elseif (!$Draft) {
                     // If the comment was not a draft
                     // If Editing a comment
                     if ($Editing) {
                         // Just reload the comment in question
                         $this->Offset = 1;
                         $Comments = $this->CommentModel->GetIDData($CommentID, array('Slave' => false));
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:67,代码来源:class.postcontroller.php

示例10: getValue

 /**
  * Gets the value associated with $FieldName.
  *
  * If the form has been posted back, it will retrieve the value from the form.
  * If it hasn't been posted back, it gets the value from $this->_DataArray.
  * Failing either of those, it returns $Default.
  *
  * @param string $FieldName
  * @param mixed $Default
  * @return mixed
  *
  * @todo check returned value type
  */
 public function getValue($FieldName, $Default = false)
 {
     $Return = '';
     // Only retrieve values from the form collection if this is a postback.
     if ($this->isMyPostBack()) {
         $Return = $this->getFormValue($FieldName, $Default);
     } else {
         $Return = arrayValue($FieldName, $this->_DataArray, $Default);
     }
     return $Return;
 }
开发者ID:adlerj,项目名称:vanilla,代码行数:24,代码来源:class.form.php

示例11: toTimestamp

 /**
  * Convert a datetime to a timestamp
  *
  * @param string $DateTime The Mysql-formatted datetime to convert to a timestamp. Should be in one
  * of the following formats: YYYY-MM-DD or YYYY-MM-DD HH:MM:SS. Returns
  * FALSE upon failure.
  * @return unknown
  */
 public static function toTimestamp($DateTime = '')
 {
     if ($DateTime === '0000-00-00 00:00:00') {
         return false;
     } elseif (($TestTime = strtotime($DateTime)) !== false) {
         return $TestTime;
     } elseif (preg_match('/^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?:\\s{1}(\\d{1,2}):(\\d{1,2})(?::(\\d{1,2}))?)?$/', $DateTime, $Matches)) {
         $Year = $Matches[1];
         $Month = $Matches[2];
         $Day = $Matches[3];
         $Hour = arrayValue(4, $Matches, 0);
         $Minute = arrayValue(5, $Matches, 0);
         $Second = arrayValue(6, $Matches, 0);
         return mktime($Hour, $Minute, $Second, $Month, $Day, $Year);
     } elseif (preg_match('/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/', $DateTime, $Matches)) {
         $Year = $Matches[1];
         $Month = $Matches[2];
         $Day = $Matches[3];
         return mktime(0, 0, 0, $Month, $Day, $Year);
         // } elseif ($DateTime == '') {
         //    return time();
     } else {
         return false;
     }
 }
开发者ID:ringoma,项目名称:vanilla,代码行数:33,代码来源:class.format.php

示例12: get

 /**
  * Get attribute value
  *
  * @param mixed $key
  * @return string
  */
 public function get($key)
 {
     return arrayValue($this->arr, $key, "");
 }
开发者ID:nonconforme,项目名称:nreeda,代码行数:10,代码来源:Attributes.class.php

示例13: json

 /**
  * If JSON is going to be sent to the client, this method allows you to add
  * extra values to the JSON array.
  *
  * @param string $Key The name of the array key to add.
  * @param mixed $Value The value to be added. If null, then it won't be set.
  * @return mixed The value at the key.
  */
 public function json($Key, $Value = null)
 {
     if (!is_null($Value)) {
         $this->_Json[$Key] = $Value;
     }
     return arrayValue($Key, $this->_Json, null);
 }
开发者ID:adlerj,项目名称:vanilla,代码行数:15,代码来源:class.controller.php

示例14: getId

 /**
  * Get the database id
  * 0 if not stored in database
  *
  * @return int
  */
 public function getId()
 {
     return (int) arrayValue($this->_dbValues, "id");
 }
开发者ID:nonconforme,项目名称:nreeda,代码行数:10,代码来源:Object.class.php

示例15: save

 /**
  * Save a message.
  *
  * @param array $FormPostValues Message data.
  * @param bool $Settings
  * @return int The MessageID.
  */
 public function save($FormPostValues, $Settings = false)
 {
     // The "location" is packed into a single input with a / delimiter. Need to explode it into three different fields for saving
     $Location = arrayValue('Location', $FormPostValues, '');
     if ($Location != '') {
         $Location = explode('/', $Location);
         $Application = val(0, $Location, '');
         if (in_array($Application, $this->_SpecialLocations)) {
             $FormPostValues['Application'] = null;
             $FormPostValues['Controller'] = $Application;
             $FormPostValues['Method'] = null;
         } else {
             $FormPostValues['Application'] = $Application;
             $FormPostValues['Controller'] = val(1, $Location, '');
             $FormPostValues['Method'] = val(2, $Location, '');
         }
     }
     Gdn::cache()->remove('Messages');
     return parent::save($FormPostValues, $Settings);
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:27,代码来源:class.messagemodel.php


注:本文中的arrayValue函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。