本文整理汇总了PHP中array_value函数的典型用法代码示例。如果您正苦于以下问题:PHP array_value函数的具体用法?PHP array_value怎么用?PHP array_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render(ddUploadify $up)
{
$widget_id = $this->getSlug() . '-input';
$form = new BaseForm();
$csrf_token = $form->getCSRFToken();
$output = '<div class="container dd-img-upload-wrapper">';
$output .= '<div id="fileQueue"></div>';
$output .= '<input type="file" name="' . $up->getSlug() . '" id="' . $widget_id . '" />';
$output .= '<p><a href="javascript:jQuery(\'#' . $widget_id . '\').uploadifyClearQueue()">Cancel All Uploads</a></p>';
$output .= '<div class="swfupload-buttontarget">
<noscript>
We\'re sorry. SWFUpload could not load. You must have JavaScript enabled to enjoy SWFUpload.
</noscript>
</div>';
$output .= '<script type="text/javascript">
//<![CDATA[
$(document).ready(function() {
$(\'#' . $widget_id . ' \').uploadify({
\'scriptData\': {\' ' . array_key($up->getSession()) . ' \': \' ' . array_value($up->getSession()) . ' \', \'_csrf_token\': \' ' . $csrf_token . ' \'},
\'uploader\': \' ' . $up->getUploader() . ' \',
\'cancelImg\': \'cancel.png\',
\'auto\' : true,
\'script\': $(\'#' . $widget_id . '\').closest(\'form\').attr(\'action\')+\'/upload\',
\'folder\': \'\',
\'multi\': false,
\'displayData\': \'speed \',
\'fileDataName\': \' ' . $widget_id . ' \',
\'simUploadLimit\': 2
});
});
//]]>
</script>';
printf($output);
}
示例2: __invoke
public function __invoke($app)
{
$config = $app['config'];
$dbSettings = (array) $config->get('database');
if (isset($dbSettings['dsn'])) {
$dsn = $dbSettings['dsn'];
} else {
// generate the dsn
$dsn = $dbSettings['type'] . ':host=' . $dbSettings['host'] . ';dbname=' . $dbSettings['name'];
}
$user = array_value($dbSettings, 'user');
$password = array_value($dbSettings, 'password');
try {
$pdo = new \PDO($dsn, $user, $password);
} catch (PDOException $e) {
$app['logger']->emergency($e);
die('Could not connect to database.');
}
if ($app['environment'] === Application::ENV_PRODUCTION) {
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
} else {
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
}
return $pdo;
}
示例3: index
public function index()
{
$this->load->library('pagination');
$input = array('limit' => $this->input->get('limit') ?: 10, 'offset' => $this->input->get('per_page') ?: '');
$order = $this->business->query($input);
$pagination_config['base_url'] = site_url('business/index?limit=' . $input['limit']);
$pagination_config['total_rows'] = array_value($order, 'count', 0);
$pagination_config['per_page'] = $input['limit'];
$pagination_config['next_link'] = '»';
$pagination_config['prev_link'] = '«';
$pagination_config['full_tag_open'] = '<div class="pagination"><ul>';
$pagination_config['full_tag_close'] = '</ul></div>';
$pagination_config['first_tag_open'] = '<li>';
$pagination_config['first_tag_close'] = '</li>';
$pagination_config['last_tag_open'] = '<li>';
$pagination_config['last_tag_close'] = '</li>';
$pagination_config['first_url'] = site_url('business/index');
$pagination_config['cur_tag_open'] = '<li class="active"><a>';
$pagination_config['cur_tag_close'] = '</a></li>';
$pagination_config['next_tag_open'] = '<li>';
$pagination_config['next_tag_close'] = '</li>';
$pagination_config['prev_tag_open'] = '<li>';
$pagination_config['prev_tag_close'] = '</li>';
$pagination_config['num_tag_open'] = '<li>';
$pagination_config['num_tag_close'] = '</li>';
$pagination_config['page_query_string'] = true;
$this->pagination->initialize($pagination_config);
$data = array('list' => array_value($order, 'data', array()), 'count' => array_value($order, 'count', 0), 'input' => $input);
$this->view($data);
}
示例4: send
public function send(array $message)
{
$to = (array) array_value($message, 'to');
if (count($to) === 0) {
return [];
}
return $this->mandrill->messages->send($message);
}
示例5: send
public function send(array $message)
{
$result = [];
$to = (array) array_value($message, 'to');
foreach ($to as $item) {
$result[] = ['_id' => Utility::guid(false), 'email' => $item['email'], 'status' => 'sent'];
}
return $result;
}
示例6: execute
/**
Executes the prepared statement.
@return mixed An instance of weeDatabaseDummyResult if the query returned rows or null.
*/
public function execute()
{
// oci_execute triggers a warning when the statement could not be executed.
@oci_execute($this->rStatement, OCI_DEFAULT) or burn('DatabaseException', sprintf(_WT("Failed to execute the query with the following error:\n%s"), array_value(oci_error($this->rStatement), 'message')));
$this->iNumAffectedRows = oci_num_rows($this->rStatement);
if (oci_num_fields($this->rStatement) > 0) {
// TODO: Check whether the silence operator is really required here.
@oci_fetch_all($this->rStatement, $aRows, 0, -1, OCI_ASSOC | OCI_FETCHSTATEMENT_BY_ROW);
return new weeDatabaseDummyResult($aRows);
}
}
示例7: _build_query
protected function _build_query($input)
{
$this->_build_base($input);
if ($limit = array_value($input, 'limit')) {
$offset = array_value($input, 'offset');
$this->db->limit($limit, $offset);
}
$this->db->order_by('id DESC');
$result = $this->db->get($this->_table_name);
return $result->num_rows() ? $result->result_array() : array();
}
示例8: __construct
/**
Initialises a new mssql database.
This database driver accepts the following parameters:
* host: The server of the database as specified by mssql_connect.
* user: The username.
* password: The password.
* dbname: The name of the database.
@param $aParams The parameters of the database.
@throw ConfigurationException The MSSQL PHP extension is missing.
@throw DatabaseException The connection failed.
*/
public function __construct($aParams = array())
{
function_exists('mssql_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'MSSQL'));
// mssql_connect triggers a warning if the connection failed.
// Don't use mssql_get_last_message here as it does not always return
// something useful on connection failure.
$this->rLink = mssql_connect(array_value($aParams, 'host'), array_value($aParams, 'user'), array_value($aParams, 'password'), true);
$this->rLink !== false or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), array_value(error_get_last(), 'message')));
if (isset($aParams['dbname'])) {
$this->selectDb($aParams['dbname']);
}
}
示例9: findPath
/**
* Get the path based on a class name.
*
* @param string The class name
*
* @return string|false Returns the path on success FALSE on failure
*/
public function findPath($classname, $basepath = null)
{
$path = false;
/*
* Exception rule for Exception classes
*
* Transform class to lower case to always load the exception class from the /exception/ folder.
*/
if ($pos = strpos($classname, 'Exception')) {
$filename = substr($classname, $pos + strlen('Exception'));
$classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
}
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
$parts = explode(' ', $word);
if (array_shift($parts) == 'com') {
//Switch the basepath
if (!empty($basepath)) {
$this->_basepath = $basepath;
}
$component = 'com_' . strtolower(array_shift($parts));
$file = array_pop($parts);
$path = null;
if (count($parts)) {
if ($parts[0] != 'view') {
foreach ($parts as $key => $value) {
$parts[$key] = KInflector::pluralize($value);
}
} else {
$parts[0] = KInflector::pluralize($parts[0]);
}
$path = implode('/', $parts);
}
$path = '/components/' . $component . '/' . $path;
$filepath = $path . '/' . $file . '.php';
$basepath = $this->_basepath;
if (array_value($parts, -1) == 'exceptions') {
if (!file_exists($basepath . $filepath)) {
$filepath = $path . '/default.php';
}
}
if (count($parts) == 2 && $parts[0] == 'domains') {
if ($parts[1] == 'entities' && JPATH_SITE != $this->_basepath) {
//set the basepath of entities to the site
if (!file_exists($basepath . $filepath)) {
$basepath = JPATH_SITE;
}
}
}
$path = $basepath . $filepath;
}
return $path;
}
示例10: __construct
/**
* @param array $options ['etag'=> bool, 'file_get_contents' => bool]
*/
public function __construct($filename, $options = array('etag' => false))
{
$this->filename = $filename;
$this->etag = array_value($options, 'etag');
if (!file_exists($filename)) {
if (basename($filename) == 'index.html') {
$this->error = new HttpError(403);
} else {
$this->error = new HttpError(404);
}
return;
}
$last_modified = filemtime($filename);
if ($last_modified === false) {
$this->error = new HttpError(500);
return;
}
if (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER)) {
$if_modified_since = strtotime(preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']));
if ($if_modified_since >= $last_modified) {
// Is the Cached version the most recent?
$this->notModified = true;
return;
}
}
if ($this->etag) {
$etag = md5_file($filename);
if (array_value($_SERVER, 'HTTP_IF_NONE_MATCH') === $etag) {
$this->notModified = true;
return;
}
$this->headers[] = 'ETag: ' . md5_file($filename);
}
$this->notModified = false;
if (is_dir($filename)) {
$this->error = new HttpError(403);
return;
}
$this->headers['Content-Type'] = \Sledgehammer\mimetype($filename);
$this->headers['Last-Modified'] = gmdate('r', $last_modified);
$filesize = filesize($filename);
if ($filesize === false) {
$this->error = new HttpError(500);
return;
}
$this->headers['Content-Length'] = $filesize;
// @todo Detecteer bestanden groter dan 2GiB, deze geven fouten.
if (array_value($options, 'file_get_contents')) {
$this->fileContents = file_get_contents($filename);
}
}
示例11: __construct
/**
Initialises a new pgsql database.
This database driver accepts the same parameters as the ones allowed in the connection string
passed to pg_connect plus "encoding", which is the encoding used by the client as specified
by pg_set_client_encoding.
The default encoding is UNICODE.
@param $aParams The parameters of the database.
@see http://php.net/pg_connect
@see http://php.net/pg_set_client_encoding
*/
public function __construct($aParams = array())
{
function_exists('pg_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'PostgreSQL'));
$sEncoding = array_value($aParams, 'encoding', 'UNICODE');
unset($aParams['encoding']);
$sConnection = null;
foreach ($aParams as $sKey => $sValue) {
$sConnection .= $sKey . "='" . str_replace(array("'", "\\"), array("\\'", "\\\\"), $sValue) . "' ";
}
// pg_connect triggers a warning if the connection failed.
$this->rLink = @pg_connect($sConnection, PGSQL_CONNECT_FORCE_NEW);
$this->rLink === false and burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), array_value(error_get_last(), 'message')));
pg_set_client_encoding($this->rLink, $sEncoding) != -1 or burn('InvalidArgumentException', sprintf(_WT('Encoding "%s" is invalid.'), $sEncoding));
}
示例12: __construct
/**
Initialises a new mysqli database.
This database driver accepts the following parameters:
* host: The host of the database server.
* user: The user of the connection to the database.
* password: The password used by the user.
* dbname: The name of the database to select.
* encoding: The encoding to use for the database connection.
Refer to the documentation of mysqli::real_connect() to know the default values
of the `host`, `user` and `password` parameters.
@param $aParams The parameters of the database.
@throw ConfigurationException The MySQLi PHP extension is missing.
@throw DatabaseException Failed to connect to the database.
@throw InvalidArgumentException The given encoding is invalid.
*/
public function __construct($aParams = array())
{
function_exists('mysqli_real_connect') or burn('ConfigurationException', sprintf(_WT('The "%s" PHP extension is required by this database driver.'), 'MySQLi'));
$this->oDb = new mysqli();
$this->oDb->init();
// mysqli_real_connect returns false and triggers a warning if the connection failed.
@$this->oDb->real_connect(array_value($aParams, 'host'), array_value($aParams, 'user'), array_value($aParams, 'password')) or burn('DatabaseException', sprintf(_WT("Failed to connect to the database with the following error:\n%s"), $this->oDb->connect_error));
if (isset($aParams['encoding'])) {
$this->oDb->set_charset($aParams['encoding']) or burn('InvalidArgumentException', sprintf(_WT('Encoding "%s" is invalid.'), $aParams['encoding']));
}
if (isset($aParams['dbname'])) {
$this->selectDb($aParams['dbname']);
}
}
示例13: __construct
/**
Establish a simple connection to an LDAP server on a specified hostname and port, and bind to the LDAP directory with the specified RDN and password.
For binding anonymously, you don't need to specify RDN and password.
Parameters:
* host: The LDAP server.
* port: The port to connect.
* rdn: The Relative Distinguished Name.
* password: The password to use.
@param $aPrams List of parameters used to initalize the connection and authentication.
@throw ConfigurationException LDAP support must be enabled.
@throw InvalidArgumentException The host parameter must be specified.
@throw LDAPException If an error occurs.
*/
public function __construct($aParams = array())
{
function_exists('ldap_connect') or burn('ConfigurationException', 'LDAP support is missing.');
$this->aParams = $aParams;
empty($aParams['host']) and burn('InvalidArgumentException', 'The host parameter must not be empty.');
$this->rLink = ldap_connect($this->aParams['host'], array_value($this->aParams, 'port', 389));
$this->rLink === false and burn('LDAPException', sprintf(_WT('Failed to connect to "%s".'), $this->aParams['host']));
// OpenLDAP2 requires the protocol version to be set
// TODO: test if this is compatible with other different LDAP servers
ldap_set_option($this->rLink, LDAP_OPT_PROTOCOL_VERSION, 3);
$b = ldap_bind($this->rLink, array_value($this->aParams, 'rdn'), array_value($this->aParams, 'password'));
if ($b === false) {
throw new LDAPException(sprintf(_WT('Could not bind the RDN "%s".'), array_value($this->aParams, 'rdn')) . "\n" . ldap_error($this->rLink), ldap_errno($this->rLink));
}
}
示例14: set
/**
Change the locale used by the application.
@param $sLocale The new locale.
*/
public function set($sLocale, $sCodeSet = 'UTF-8', $sModifier = null)
{
if (strlen($sLocale) == 2) {
$sLocale = array_value($this->aLocaleMap, $sLocale, $sLocale);
}
if (strlen($sLocale) > 1) {
if (!is_null($sCodeSet)) {
$sLocale .= '.' . $sCodeSet;
}
if (!is_null($sModifier)) {
$sLocale .= '@' . $sModifier;
}
}
setlocale(LC_ALL, $sLocale) or burn('UnexpectedValueException', _WT('An error occurred while trying to set the locale.'));
}
示例15: array_value
function array_value($array)
{
$html = "";
foreach ($array as $key => $value) {
if (is_array($value)) {
$html .= array_value($value, ++$count);
} else {
if ($key == 'full_name') {
$html .= "<tr><td><a href='#' id='github_curl' title='" . $value . "'>" . $value . "</a></td>";
}
if ($key == 'created_at') {
$html .= "<td>" . $value . "</td></tr>";
}
}
}
return $html;
}