本文整理汇总了PHP中array_search函数的典型用法代码示例。如果您正苦于以下问题:PHP array_search函数的具体用法?PHP array_search怎么用?PHP array_search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_search函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: move
/**
* swap the ordering of a record in the Xref tables
* @param $direction , 1/-1 The increment to reorder by
*/
function move($direction, $where = '', $orderingkey = 0)
{
if (empty($this->_skey)) {
vmError('No secondary keys defined in VmTableXarray ' . $this->_tbl);
return false;
}
$skeyId = vRequest::getInt($this->_skey, 0);
// Initialize variables
$db = JFactory::getDBO();
$cid = vRequest::getInt($this->_pkey);
$order = vRequest::getInt('order');
//I found now two times "order" instead of ordering.
//This sql is broken
$query = 'SELECT `id` FROM `' . $this->_tbl . '` WHERE ' . $this->_pkey . ' = ' . (int) $cid[0] . ' AND `tsmart_category_id` = ' . (int) $skeyId;
$db->setQuery($query);
$id = $db->loadResult();
$keys = array_keys($order);
// TODO next 2 lines not used ????
if ($direction > 0) {
$idToSwap = $order[$keys[array_search($id, $keys)] + 1];
} else {
$idToSwap = $order[$keys[array_search($id, $keys)] - 1];
}
if (isset($cid[0])) {
$query = 'UPDATE `' . $this->_tbl . '` ' . ' SET `' . $this->_orderingKey . '` = `' . $this->_orderingKey . '` + ' . $direction . ' WHERE `' . $this->_pkey . '` = ' . (int) $cid[0] . ' AND `' . $this->_skey . '` = ' . (int) $skeyId;
$db->setQuery($query);
if (!$db->execute()) {
$err = $db->getErrorMsg();
JError::raiseError(500, get_class($this) . ':: move ' . $err);
}
}
}
示例2: correctImagePath
function correctImagePath($match)
{
$context = Model_Context::getInstance();
$pathArr = explode("/", $match[1]);
if (false === $pathArr) {
return $match[0];
}
$c = count($pathArr);
if ($c <= 1) {
return $match[0];
}
if ($pathArr[$c - 1] == "") {
return $match[0];
}
// ./s/b/c/ 이런식으로 경로만 들어있는 경우 스킵
if (false !== array_search("http:", $pathArr)) {
return $match[0];
}
// full url의 경우 스킵
if ($pathArr[0] != '.' && $pathArr[0] != '..') {
return $match[0];
}
//첫 디렉토리가 현재 디렉토리가 아닌경우 스킵
return str_replace($match[1], $context->getProperty('uri.service') . "/skin/" . $context->getProperty('skin.skin') . "/" . $match[1], $match[0]);
}
示例3: test_encode_ip_range
function test_encode_ip_range()
{
$ip_list = $this->ip->encode_ip_range('192.168.0.1', '192.168.10.10');
$this->assertNotIdentical(false, array_search($this->ip->encode_ip('192.168.0.1'), $ip_list));
$this->assertNotIdentical(false, array_search($this->ip->encode_ip('192.168.10.10'), $ip_list));
}
示例4: display_add_field
function display_add_field($recordid = 0)
{
global $CFG;
$content = array();
if ($recordid) {
$content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid);
$content = explode('##', $content);
}
$str = '<div title="' . s($this->field->description) . '">';
$str .= '<fieldset><legend><span class="accesshide">' . $this->field->name . '</span></legend>';
$i = 0;
foreach (explode("\n", $this->field->param1) as $checkbox) {
$checkbox = trim($checkbox);
if ($checkbox === '') {
continue;
// skip empty lines
}
$str .= '<input type="checkbox" id="field_' . $this->field->id . '_' . $i . '" name="field_' . $this->field->id . '[]" ';
$str .= 'value="' . s($checkbox) . '" ';
if (array_search($checkbox, $content) !== false) {
$str .= 'checked />';
} else {
$str .= '/>';
}
$str .= '<label for="field_' . $this->field->id . '_' . $i . '">' . $checkbox . '</label><br />';
$i++;
}
$str .= '</fieldset>';
$str .= '</div>';
return $str;
}
示例5: 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));
}
}
}
}
示例6: detach
public function detach(odObserver $observer)
{
if (is_int($key = array_search($observer, $this->__observers, true))) {
unset($this->__observers[$key]);
}
return $this;
}
示例7: read
private function read($arg)
{
$sql = 'SELECT ';
$fields = array();
if ($arg == null) {
$this->fields = array_values($this->modelInfo['fields']);
foreach ($this->modelInfo['fields'] as $k => $v) {
array_push($fields, $k . ' as ' . $v);
}
} else {
$args = explode(',', $arg);
$this->fields = $args;
foreach ($args as $v) {
array_push($fields, array_search($v, $this->modelInfo['fields']) . ' as ' . $v);
}
}
$sql .= join(',', $fields);
$sql .= ' FROM ' . join(',', $this->modelInfo['tables']);
$sql .= ' WHERE ' . join(' and ', $this->modelInfo['links']);
if ($this->where) {
$sql .= ' and ' . $this->where;
}
if ($this->order) {
$sql .= ' ORDER BY ' . $this->order;
}
if ($this->limit) {
$sql .= ' LIMIT ' . $this->limit;
}
DEVE and debug::$sql[] = $sql;
$mysqli = $this->mysqli->prepare($sql) or debug::error('没有查询到数据!', 113004);
$mysqli->execute();
$mysqli->store_result();
return $mysqli;
}
示例8: CustomerFuKuan_add
function CustomerFuKuan_add($fields, $i)
{
global $db, $_SESSION, $common_html;
$notnull = trim($fields['null'][$i]['inputtype']);
$notnull == 'notnull' ? $notnulltext = $common_html['common_html']['mustinput'] : ($notnulltext = '');
$fieldname1 = $fields['name'][$i];
$fieldname2 = $fields['input'][$i][0];
$j = array_search($fieldname2, $fields['name'], true);
$notnull = trim($fields['null'][$j]['inputtype']);
$notnull == 'notnull' ? $notnulltext1 = $common_html['common_html']['mustinput'] : ($notnulltext1 = '');
$action = $fields['input'][$i][1];
$class = "SmallSelect";
print "<script type=\"text/javascript\" language=\"javascript\" src=\"" . ROOT_DIR . "general/ERP/Enginee/jquery/jquery.js\"></script>";
print "<script language=javascript>\n\n\$(document).ready(function (){\t\n\t\n\tif(document.form1.accountid)\n\t\tdocument.form1.accountid.options[document.form1.accountid.length] = new Option('预付款支付', '0');";
if ($fields['value'][$fieldname1] != '') {
print "changelocation(" . $fields['value'][$fieldname1] . ");\n\t\t getPayType(" . $fields['value'][$fieldname2] . ");";
}
print "});\nfunction changelocation(locationid)\n{\n\tdocument.form1.{$fieldname2}.length = 0;\n\tif(locationid!='')\n\t{\n \tsendRequest('{$action}','customerid='+locationid);\n \tgetPayType(document.form1.{$fieldname2}.value);\n \t\n }\n\t\n}\nfunction getPayType(billid)\n{\n \tsendRequest('caigouinfo','billid='+billid);\n}\nvar totalmoney=0;\nvar huikuanjine=0;\nvar kaipiaojine=0;\nvar quling=0; \nfunction sendRequest(action,params) {\n\$.ajax({ \n\t\t type:'GET', \n\t\t url:'getLinkmanBycustomer.php?action='+action+'&'+params, \n\t\t dataType: 'xml', \n\t\t cache:false,\n\t\t async: false,\n\t\t success:function(data) \n\t\t { \n\t\t \tif(action=='fukuan' || action=='shoupiao')\n \t\t \t{\n \t\t\n\t\t \t";
print "var yuchuzhi=\$(data).find('chuzhi').text();\n \t\t \t\t\t\$('#yuchuzhi').text(yuchuzhi+' 元');\n\n \t\t \t\t \$(data).find('sellbuy').each(function(i) {\n \t\n\t\t\t\t\t\tvar rowid=\$(this).children('rowid').text();\n\t\t\t\t\t\tvar zhuti=\$(this).children('zhuti').text();\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\tdocument.form1.{$fieldname2}.options[document.form1.{$fieldname2}.length] = new Option(zhuti, rowid);\n\t\t\t\t\t\tif(rowid=='" . $fields['value'][$fieldname2] . "')\n\t\t\t\t\t\t\tdocument.form1.{$fieldname2}.options[document.form1.{$fieldname2}.length-1].selected=true;\n\t\t\t\t\t\ti++;\n });\t\n \t\t \t}\n \t\t \tif(action=='caigouinfo')\n \t\t \t{\n \t\t\n\t\t\t\t\$(data).find('caigouinfo').each(function(i) {\n\t\t\t\t\tif(\$(this).children('totalmoney')!=null)\n\t\t\t\t\t \ttotalmoney=\$(this).children('totalmoney').text();\n\t\t\t\t\tif(\$(this).children('paymoney')!=null) \n\t\t\t\t\t \thuikuanjine=\$(this).children('paymoney').text();\n\t\t\t\t\tif(\$(this).children('shoupiaomoney')!=null)\n\t\t\t\t\t \tkaipiaojine=\$(this).children('shoupiaomoney').text();\n\t \t\t \t\tif(\$(this).children('oddment')!=null)\n\t\t\t\t\t \tquling=\$(this).children('oddment').text(); \t\n\t\t\t\t\t \t\t\n\t \t\t \t\t\$('#totalmoney').text(totalmoney);\n\t \t\t \t\t\$('#paymoney').text(huikuanjine);\n\t \t\t \t\t\$('#shoupiaomoney').text(kaipiaojine);\n\t \t\t \t\t\$('#oddment').text(quling);\n\t \t\t \t\tif(form1.jine!=null)\n\t \t\t \t\t\tform1.jine.value=delFormat(totalmoney)-delFormat(huikuanjine)-delFormat(quling);\n\t \t\t \t\tif(form1.piaojujine!=null)\n\t \t\t \t\t\tform1.piaojujine.value=delFormat(totalmoney)-delFormat(kaipiaojine);\n\t \t\t \t\tif(form1.oddment!=null)\n\t \t\t \t\t\tform1.oddment.value=0;\n \t\t \t\t});\t\n \t\t \t}\n\t \t\t \t\t\t\t\n\t\t },\n\t\t error:function(XmlHttpRequest,textStatus, errorThrown)\n\t {\n\t\t\t var errorPage = XmlHttpRequest.responseText; \n\t\t\t alert('获取采购单出错:'+errorThrown);\n\t }\n\t});\n\n}\n\n</SCRIPT>\n";
print "<TR><TD class=TableData noWrap>供应商:</TD><TD class=TableData noWrap>\n";
$supplyname = returntablefield("supply", "rowid", $fields['value'][$fieldname1], "supplyname");
$fieldnameID = $fieldname1 . "_ID";
print "<input type=\"hidden\" name=\"{$fieldname1}\" value=\"" . $fields['value'][$fieldname1] . "\" onchange='changelocation(this.value);'>";
print "<input name=\"" . $fieldnameID . "\" value=\"" . $supplyname . "\" class=\"SmallStatic\" readonly size=30> \n";
print "<input type=\"button\" title='' value=\"选择\" class=\"SmallButton\" onClick=\"SelectAllInforSingle('../../Enginee/Module/supply_select_single/index.php','','{$fieldnameID}', '{$fieldname1}');\" > {$notnulltext}";
print "<TR><TD class=TableData noWrap>预付款:</TD><TD class=TableData noWrap><div id='yuchuzhi'></div></TD></TR>\n";
print "<TR><TD class=TableData noWrap>采购单:</TD><TD class=TableData noWrap>\n";
print "<SELECT onkeydown=\"if(event.keyCode==13)event.keyCode=9\" class=\"{$class}\" \n";
print "size=1 name='" . $fieldname2 . "' onchange=\"getPayType(this.value);\"></SELECT> {$notnulltext1}</TD></TR>\n";
print "<TR><TD class=TableData noWrap>总金额:</TD><TD class=TableData noWrap><div id='totalmoney'></div></TD></TR>\n";
print "<TR><TD class=TableData noWrap>已去零:</TD><TD class=TableData noWrap><div id='oddment'></div></TD></TR>\n";
print "<TR><TD class=TableData noWrap>已付款金额:</TD><TD class=TableData noWrap><div id='paymoney'></div></TD></TR>\n";
print "<TR><TD class=TableData noWrap>已收票金额:</TD><TD class=TableData noWrap><div id='shoupiaomoney'></div></TD></TR>\n";
}
示例9: dieIfDirectoriesNotWritable
/**
* Checks that the directories Piwik needs write access are actually writable
* Displays a nice error page if permissions are missing on some directories
*
* @param array $directoriesToCheck Array of directory names to check
*/
public static function dieIfDirectoriesNotWritable($directoriesToCheck = null)
{
$resultCheck = self::checkDirectoriesWritable($directoriesToCheck);
if (array_search(false, $resultCheck) === false) {
return;
}
$directoryList = '';
foreach ($resultCheck as $dir => $bool) {
$realpath = Filesystem::realpath($dir);
if (!empty($realpath) && $bool === false) {
$directoryList .= self::getMakeWritableCommand($realpath);
}
}
// Also give the chown since the chmod is only 755
if (!SettingsServer::isWindows()) {
$realpath = Filesystem::realpath(PIWIK_INCLUDE_PATH . '/');
$directoryList = "<code>chown -R www-data:www-data " . $realpath . "</code><br />" . $directoryList;
}
if (function_exists('shell_exec')) {
$currentUser = trim(shell_exec('whoami'));
if (!empty($currentUser)) {
$optionalUserInfo = " (running as user '" . $currentUser . "')";
}
}
$directoryMessage = "<p><b>Piwik couldn't write to some directories {$optionalUserInfo}</b>.</p>";
$directoryMessage .= "<p>Try to Execute the following commands on your server, to allow Write access on these directories" . ":</p>" . "<blockquote>{$directoryList}</blockquote>" . "<p>If this doesn't work, you can try to create the directories with your FTP software, and set the CHMOD to 0755 (or 0777 if 0755 is not enough). To do so with your FTP software, right click on the directories then click permissions.</p>" . "<p>After applying the modifications, you can <a href='index.php'>refresh the page</a>.</p>" . "<p>If you need more help, try <a href='?module=Proxy&action=redirect&url=http://piwik.org'>Piwik.org</a>.</p>";
Piwik_ExitWithMessage($directoryMessage, false, true);
}
示例10: interact
/**
* {@inheritdoc}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
$dialog = $this->getDialogHelper();
// --module option
$module = $input->getOption('module');
if (!$module) {
// @see Drupal\Console\Command\ModuleTrait::moduleQuestion
$module = $this->moduleQuestion($output, $dialog);
}
$input->setOption('module', $module);
// --content type argument
$content_type = $input->getArgument('content_type');
if (!$content_type) {
$entity_manager = $this->getEntityManager();
$bundles_entities = $entity_manager->getStorage('node_type')->loadMultiple();
$bundles = array();
foreach ($bundles_entities as $entity) {
$bundles[$entity->id()] = $entity->label();
}
$content_type = $dialog->askAndValidate($output, $dialog->getQuestion($this->trans('commands.config.export.content.type.questions.content_type'), ''), function ($bundle) use($bundles) {
if (!in_array($bundle, array_values($bundles))) {
throw new \InvalidArgumentException(sprintf('Content type "%s" is invalid.', $bundle));
}
return array_search($bundle, $bundles);
}, false, '', $bundles);
}
$input->setArgument('content_type', $content_type);
}
示例11: addPaymentMethod
/**
* Add PayPal payment method set EN and DE long descriptions
*/
public static function addPaymentMethod()
{
$aPaymentDescriptions = array('en' => '<div>When selecting this payment method you are being redirected to PayPal where you can login into your account or open a new account. In PayPal you are able to authorize the payment. As soon you have authorized the payment, you are again redirected to our shop where you can confirm your order.</div> <div style="margin-top: 5px">Only after confirming the order, transfer of money takes place.</div>', 'de' => '<div>Bei Auswahl der Zahlungsart PayPal werden Sie im nächsten Schritt zu PayPal weitergeleitet. Dort können Sie sich in Ihr PayPal-Konto einloggen oder ein neues PayPal-Konto eröffnen und die Zahlung autorisieren. Sobald Sie Ihre Daten für die Zahlung bestätigt haben, werden Sie automatisch wieder zurück in den Shop geleitet, um die Bestellung abzuschließen.</div> <div style="margin-top: 5px">Erst dann wird die Zahlung ausgeführt.</div>');
$oPayment = oxNew('oxPayment');
if (!$oPayment->load('oxidpaypal')) {
$oPayment->setId('oxidpaypal');
$oPayment->oxpayments__oxactive = new oxField(1);
$oPayment->oxpayments__oxdesc = new oxField('PayPal');
$oPayment->oxpayments__oxaddsum = new oxField(0);
$oPayment->oxpayments__oxaddsumtype = new oxField('abs');
$oPayment->oxpayments__oxfromboni = new oxField(0);
$oPayment->oxpayments__oxfromamount = new oxField(0);
$oPayment->oxpayments__oxtoamount = new oxField(10000);
$oLanguage = oxRegistry::get('oxLang');
$aLanguages = $oLanguage->getLanguageIds();
foreach ($aPaymentDescriptions as $sLanguageAbbreviation => $sDescription) {
$iLanguageId = array_search($sLanguageAbbreviation, $aLanguages);
if ($iLanguageId !== false) {
$oPayment->setLanguage($iLanguageId);
$oPayment->oxpayments__oxlongdesc = new oxField($sDescription);
$oPayment->save();
}
}
}
}
示例12: getAvailable
/**
* return an array of all available theme (installed or not)
*
* @param boolean $installed_only
* @return array string (directory)
*/
public static function getAvailable($installed_only = true)
{
static $dirlist = array();
$available_theme = array();
if (empty($dirlist)) {
$themes = scandir(_PS_ALL_THEMES_DIR_);
foreach ($themes as $theme) {
if (is_dir(_PS_ALL_THEMES_DIR_ . DIRECTORY_SEPARATOR . $theme) && $theme[0] != '.') {
$dirlist[] = $theme;
}
}
}
if ($installed_only) {
$themes = Theme::getThemes();
foreach ($themes as $theme_obj) {
$themes_dir[] = $theme_obj->directory;
}
foreach ($dirlist as $theme) {
if (false !== array_search($theme, $themes_dir)) {
$available_theme[] = $theme;
}
}
} else {
$available_theme = $dirlist;
}
return $available_theme;
}
示例13: removeTab
/**
* @param Psc\UI\jqx\Tab $tab
* @chainable
*/
public function removeTab(Tab $tab)
{
if (($key = array_search($tab, $this->tabs, TRUE)) !== FALSE) {
array_splice($this->tabs, $key, 1);
}
return $this;
}
示例14: laser
function laser($inimigos)
{
if (empty($inimigos)) {
return 0;
}
$linhas = $colunas = array();
foreach ($inimigos as $inimigo) {
if (!isset($linhas[$inimigo->x])) {
$linhas[$inimigo->x] = 0;
}
if (!isset($colunas[$inimigo->y])) {
$colunas[$inimigo->y] = 0;
}
$linhas[$inimigo->x]++;
$colunas[$inimigo->y]++;
}
// Escolhe qual linha ou coluna atirar
if (count($linhas) < count($colunas)) {
$maiorLinha = array_search(max($linhas), $linhas);
$maiorColuna = false;
} else {
$maiorColuna = array_search(max($colunas), $colunas);
$maiorLinha = false;
}
// Remove os inimigos da linha/coluna escolhida
foreach ($inimigos as $key => $inimigo) {
if ($inimigo->x === $maiorLinha or $inimigo->y === $maiorColuna) {
unset($inimigos[$key]);
}
}
return 1 + laser($inimigos);
}
示例15: treeView
function treeView($array, $id = 0, $allCategories, $productData)
{
foreach ($array as $keyArray => $valueArray) {
if ($array[$keyArray]->parent_category_id == $id) {
$flag = array_search($array[$keyArray]->category_id, array_column(json_decode(json_encode($allCategories), true), 'parent_category_id'));
if ($flag) {
?>
<optgroup
label="<?php
echo $array[$keyArray]->display_name . $array[$keyArray]->category_name;
?>
">
<?php
treeView($array, $array[$keyArray]->category_id, $allCategories, $productData);
?>
</optgroup>
<?php
} else {
?>
<option value="{{$array[$keyArray]->category_id }}" @if($array[$keyArray]->category_id == $productData['category_id']){{"selected"}}@endif>
<?php
echo $array[$keyArray]->display_name . $array[$keyArray]->category_name;
?>
</option>
<?php
}
}
}
}