本文整理汇总了PHP中lTrim函数的典型用法代码示例。如果您正苦于以下问题:PHP lTrim函数的具体用法?PHP lTrim怎么用?PHP lTrim使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lTrim函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _validate_ip_addr
function _validate_ip_addr($ipaddr)
{
$ipaddr = trim($ipaddr);
if (!preg_match('/^([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})\\.([0-9]{1,3})$/', $ipaddr, $m)) {
return false;
}
for ($i = 1; $i <= 4; ++$i) {
$m[$i] = (int) lTrim($m[$i], '0');
if ($m[$i] > 255) {
return false;
}
}
$ipaddr = $m[1] . '.' . $m[2] . '.' . $m[3] . '.' . $m[4];
if (in_array(@ip2long($ipaddr), array(false, null, -1, 0), true)) {
return false;
}
return $ipaddr;
}
示例2: gs_log
} else {
gs_log(GS_LOG_NOTICE, "IP {$remote_ip} is not in GS_CALL_INIT_FROM_NET => not allowed to init call");
die_not_allowed('You are not allowed to init a call.');
}
#####################################################################
# user
#####################################################################
if (!isset($_REQUEST['user'])) {
gs_log(GS_LOG_NOTICE, 'No user code specified. Use user=');
die_invalid('No user code specified. Use user=');
}
$user_code = trim($_REQUEST['user']);
if (gs_get_conf('GS_LVM_USER_6_DIGIT_INT')) {
# hack to compare user names as if they were integers
# padded to 6 digits
$user_code = lTrim($user_code, '0');
if (strLen($user_code) < 6) {
$user_code = str_pad($user_code, 6, '0', STR_PAD_LEFT);
}
}
$user = @gs_user_get($user_code);
if (isGsError($user)) {
gs_log(GS_LOG_NOTICE, $user->getMsg());
die_invalid($user->getMsg());
}
if ($user['nobody_index'] > 0) {
gs_log(GS_LOG_NOTICE, 'Nobody user. Not allowed to init a call.');
die_not_allowed('Nobody user. Not allowed to init a call.');
}
$db = gs_db_master_connect();
if (!$db) {
示例3: widget
function widget($args, $instance)
{
extract($args);
/* ------------------------------------
:: WIDGET VARIABLES
------------------------------------ */
// Option Keys
$keys = array('width', 'height', 'gallery_height', 'imgheight', 'imgwidth', 'img_align', 'timeout', 'orderby', 'sortby', 'tween', 'animation', 'animation_type', 'title', 'excerpt', 'datasource', 'attachedmedia', 'pagepost_id', 'gallerycats', 'gallerypostformat', 'flickr_set', 'slidesetid', 'productcats', 'producttags', 'mediacats');
foreach ($keys as $key) {
if (empty($instance[$key])) {
$instance[$key] = '';
}
}
$title = apply_filters('widget_title', $instance['title']);
if (!$instance['width']) {
$NV_imgwidth = '290';
} else {
$NV_imgwidth = $instance['width'];
}
if (!$instance['height']) {
$NV_imgheight = '170';
} else {
$NV_imgheight = $instance['height'];
}
if (!$instance['gallery_height']) {
$NV_galleryheight = '200';
} else {
$NV_galleryheight = $instance['gallery_height'];
}
$NV_galleryheight = 'height="' . $NV_galleryheight . '"';
$NV_imgheight = 'imgheight="' . $NV_imgheight . '"';
$NV_imgwidth = 'imgwidth="' . $NV_imgwidth . '"';
if ($instance['excerpt']) {
$excerpt = 'excerpt="' . $instance['excerpt'] . '"';
} else {
$excerpt = '';
}
if ($instance['img_align']) {
$image_align = 'image_align="' . $instance['img_align'] . '"';
} else {
$image_align = '';
}
$timeout = $instance['timeout'] != '' ? 'timeout="' . $instance['timeout'] . '"' : 'timeout="10"';
if ($instance['orderby']) {
$orderby = 'orderby="' . $instance['orderby'] . '"';
} else {
$orderby = '';
}
if ($instance['sortby']) {
$sortby = 'sortby="' . $instance['sortby'] . '"';
} else {
$sortby = '';
}
$tween = 'tween="' . $instance['tween_type'] . '"';
$animation = 'animation="' . $instance['animation_type'] . '"';
/* ------------------------------------
:: DISPLAY WIDGET
------------------------------------ */
echo "<li class=\"widget sidebar-slider\">";
/* Display the widget title if one was input (before and after defined by themes). */
if (isset($title)) {
echo $before_title . $title . $after_title;
}
$chars = array("[", "]", "-");
global $NV_is_widget;
$NV_is_widget = true;
$galid = str_replace($chars, "", $this->get_field_name('id'));
if ($instance['datasource'] == $this->get_field_id('data-1')) {
$NV_datasource = 'attached_id="' . $instance['attachedmedia'] . '"';
} elseif ($instance['datasource'] == $this->get_field_id('data-2') || $instance['gallerycats'] != '') {
if ($instance['gallerycats'] != '') {
$string = '';
foreach ($instance['gallerycats'] as $value) {
$string = $string . $value . ",";
}
$cats = lTrim($string, ',');
$NV_datasource = 'categories="' . $cats . '"';
}
if ($instance['gallerypostformat'] != '') {
$NV_datasource .= $NV_datasource . ' post_format="' . $instance['gallerypostformat'] . '"';
}
} elseif ($instance['datasource'] == $this->get_field_id('data-3')) {
$NV_datasource = 'flickr_set="' . $instance['flickrset'] . '"';
} elseif ($instance['datasource'] == $this->get_field_id('data-4') || $instance['slidesetid'] != '') {
$string = '';
foreach ($instance['slidesetid'] as $value) {
$string = $string . $value . ",";
}
$slidesets = lTrim($string, ',');
$NV_datasource = 'slidesetid="' . $slidesets . '"';
} elseif ($instance['datasource'] == $this->get_field_id('data-5')) {
if ($instance['productcats']) {
foreach ($instance['productcats'] as $value) {
$string = $string . $value . ",";
}
$pcats = lTrim($string, ',');
$NV_datasource = 'product_categories="' . $pcats . '"';
}
if ($instance['producttags']) {
foreach ($instance['producttags'] as $value) {
//.........这里部分代码省略.........
示例4: abs
{
if ($val > $max) {
$val = $max;
}
if ($val < $min) {
$val = $min;
}
}
$action = @$_REQUEST['action'];
if ($action === 'report') {
$fr_y = abs((int) lTrim(@$_REQUEST['fr_y'], '0'));
$fr_m = abs((int) lTrim(@$_REQUEST['fr_m'], '0'));
$fr_d = abs((int) lTrim(@$_REQUEST['fr_d'], '0'));
$to_y = abs((int) lTrim(@$_REQUEST['to_y'], '0'));
$to_m = abs((int) lTrim(@$_REQUEST['to_m'], '0'));
$to_d = abs((int) lTrim(@$_REQUEST['to_d'], '0'));
_check_range($fr_y, 1980, 2030);
_check_range($to_y, 1980, 2030);
_check_range($fr_m, 1, 12);
_check_range($to_m, 1, 12);
_check_range($fr_d, 1, (int) date('t', mkTime(12, 1, 1, $fr_m, 15, $fr_y)));
_check_range($to_d, 1, (int) date('t', mkTime(12, 1, 1, $to_m, 15, $to_y)));
} else {
$action = '';
$now = time();
$default_to = $now;
$default_fr = $now - 7 * 24 * 3600;
$fr_y = (int) date('Y', $default_fr);
$fr_m = (int) date('n', $default_fr);
$fr_d = (int) date('j', $default_fr);
$to_y = (int) date('Y', $default_to);
示例5: _normalize_ip_addr
function _normalize_ip_addr($addr)
{
$addr = preg_replace('/[^0-9.]/', '', $addr);
if ($addr == '') {
return null;
}
$addr_parts = explode('.', $addr);
$addr = '';
for ($i = 0; $i <= 3; ++$i) {
$part = (int) lTrim(@$addr_parts[$i], '0 ');
if ($part > 255) {
$part = 255;
} elseif ($part < 0) {
$part = 0;
}
$addr .= $part;
if ($i < 3) {
$addr .= '.';
}
}
return $addr;
}
示例6: array
/*
$out = array(
' * Port 1 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0',
' * Port 2 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0',
' * Port 3 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0',
' * Port 4 Type TE Prot. PMP L2Link DOWN L1Link:DOWN Blocked:0 Debug:0'
);
$err = 0;
*/
if ($err === 0) {
foreach ($out as $line) {
$line = strToLower($line);
if (!preg_match('/ port[\\s:]*([0-9]+)/', $line, $m)) {
continue;
}
$port = (int) lTrim($m[1], '0');
if (preg_match('/ type[\\s:]*(te|nt)/', $line, $m)) {
$asterisk_misdn_ports[$port]['type'] = strToLower($m[1]);
} else {
$asterisk_misdn_ports[$port]['type'] = null;
}
if (preg_match('/ prot\\.[\\s:]*(ptp|pmp)/', $line, $m)) {
$asterisk_misdn_ports[$port]['protocol'] = strToLower($m[1]);
if ($asterisk_misdn_ports[$port]['protocol'] === 'pmp') {
$asterisk_misdn_ports[$port]['protocol'] = 'ptmp';
}
} else {
$asterisk_misdn_ports[$port]['protocol'] = null;
}
if (preg_match('/ l1link[\\s:]*(down|up)/', $line, $m)) {
$asterisk_misdn_ports[$port]['l1link'] = strToLower($m[1]);
示例7: gs_log
if ($GS_Softkeys->retrieve_keys($phone_type, array('{GS_PROV_HOST}' => gs_get_conf('GS_PROV_HOST'), '{GS_P_PBX}' => $pbx, '{GS_P_EXTEN}' => $user_ext, '{GS_P_ROUTE_PREFIX}' => $hp_route_prefix, '{GS_P_USER}' => $user['user']))) {
$softkeys = $GS_Softkeys->get_keys();
}
}
if (!is_array($softkeys)) {
gs_log(GS_LOG_WARNING, 'Failed to get softkeys');
} else {
foreach ($softkeys as $key_name => $key_defs) {
if (array_key_exists('slf', $key_defs)) {
$key_def = $key_defs['slf'];
} elseif (array_key_exists('inh', $key_defs)) {
$key_def = $key_defs['inh'];
} else {
continue;
}
$key_idx = (int) lTrim(subStr($key_name, 1), '0');
if ($key_idx > $max_key - 1) {
continue;
}
if ($key_def['function'] === 'empty') {
continue;
}
//setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active'));
if ($key_idx < 7) {
# gxp2000, gxp2010, gxp2020
psetting('P' . ($key_idx + 323), subStr($key_def['function'], 1));
//psetting('P'.($key_idx*3+301), '0');
//psetting('P'.($key_idx*3+302), '');
psetting('P' . ($key_idx * 3 + 303), $key_def['data']);
} elseif ($key_idx >= 7) {
# gxp2010
示例8: str_pad
$mf = 59;
}
$mf = str_pad($mf, 2, '0', STR_PAD_LEFT);
echo '<span class="nobr">';
echo '<input type="text" name="' . $route['id'] . '-r_h_from_h" value="', $hf, '" size="2" maxlength="2" class="r" />:';
echo '<input type="text" name="' . $route['id'] . '-r_h_from_m" value="', $mf, '" size="2" maxlength="2" class="r" /> -';
echo '</span> ', "\n";
$tmp = explode(':', $route['h_to']);
$ht = (int) lTrim(@$tmp[0], '0-');
if ($ht < 0) {
$ht = 0;
} elseif ($ht > 24) {
$ht = 24;
}
$ht = str_pad($ht, 2, '0', STR_PAD_LEFT);
$mt = (int) lTrim(@$tmp[1], '0-');
if ($mt < 0) {
$mt = 0;
} elseif ($mt > 59) {
$mt = 59;
}
$mt = str_pad($mt, 2, '0', STR_PAD_LEFT);
if ($ht . ':' . $mt < $hf . ':' . $mf) {
$ht = $hf;
$hm = $mf;
}
echo '<span class="nobr">';
echo '<input type="text" name="' . $route['id'] . '-r_h_to_h" value="', $ht, '" size="2" maxlength="2" class="r" />:';
echo '<input type="text" name="' . $route['id'] . '-r_h_to_m" value="', $mt, '" size="2" maxlength="2" class="r" />';
echo '</span>';
echo '</td>', "\n";
示例9: genDurationInWords
function genDurationInWords($a)
{
$engStr = '';
$mStr = '';
$sStr = '';
$cnt = count($a);
//hours
if ($cnt == 3) {
if ($a[0] != '') {
$n = lTrim($a[0], '0');
if ($n == 1) {
$engStr = $n . ' hour';
} else {
if ($n != 0) {
$engStr = $n . ' hours';
}
}
}
}
//minutes
if ($cnt == 3) {
$i = 1;
} else {
if ($cnt == 2) {
$i = 0;
}
}
if ($a[$i] != '') {
$n = lTrim($a[$i], '0');
if ($n == 1) {
$mStr = $n . ' minute';
} else {
if ($n != 0) {
$mStr = $n . ' minutes';
}
}
}
//seconds
if ($cnt == 3) {
$i = 2;
} else {
if ($cnt == 2) {
$i = 1;
} else {
$i = 0;
}
}
if ($a[$i] != '') {
$n = lTrim($a[$i], '0');
if ($n == 1) {
$sStr = $n . ' second';
} else {
if ($n != 0) {
$sStr = $n . ' seconds';
}
}
}
return $engStr . ' ' . $mStr . ' ' . $sStr;
}
示例10: isNamespaceClass
/**
* @return boolean
* @param string $className
* @param string $namespace
*/
protected static function isNamespaceClass($className, $namespace)
{
return 0 === strPos(lTrim($className, NS), $namespace . NS);
}
示例11: foreach
foreach ($m as $lease_def) {
$ip_addr = $lease_def[1];
$lease = array('start' => null, 'end' => null, 'hwt' => null, 'mac' => null, 'name' => null, 'bstate' => 'active');
$lease_def = subStr($lease_def[0], 6 + strLen($ip_addr) + 1);
$lm = array();
preg_match_all('/^\\s*([a-z\\-]+)\\s*([^;\\n$]*)/mS', $lease_def, $lm, PREG_SET_ORDER);
foreach ($lm as $line_def) {
switch ($line_def[1]) {
case 'starts':
if (preg_match('/^[0-6]\\s+([0-9]{4})\\/([0-9]{2})\\/([0-9]{2})\\s+([0-9]{2}):([0-9]{2}):([0-9]{2})/S', $line_def[2], $p)) {
$lease['start'] = gmMkTime((int) lTrim($p[4], '0'), (int) lTrim($p[5], '0'), (int) lTrim($p[6], '0'), (int) lTrim($p[2], '0'), (int) lTrim($p[3], '0'), (int) lTrim($p[1], '0'));
}
break;
case 'ends':
if (preg_match('/^[0-6]\\s+([0-9]{4})\\/([0-9]{2})\\/([0-9]{2})\\s+([0-9]{2}):([0-9]{2}):([0-9]{2})/S', $line_def[2], $p)) {
$lease['end'] = gmMkTime((int) lTrim($p[4], '0'), (int) lTrim($p[5], '0'), (int) lTrim($p[6], '0'), (int) lTrim($p[2], '0'), (int) lTrim($p[3], '0'), (int) lTrim($p[1], '0'));
} elseif (preg_match('/^never/S', $line_def[2], $p)) {
$lease['end'] = PHP_INT_MAX;
}
break;
case 'hardware':
if (preg_match('/^([a-z0-9\\-_]+)\\s+(([0-9a-zA-Z]{1,2}:?)+)/S', $line_def[2], $p)) {
$lease['hwt'] = $p[1];
switch ($lease['hwt']) {
case 'ethernet':
$lease['hwt'] = 'en';
break;
case 'unknown-0':
$lease['hwt'] = 'u0';
break;
case 'unknown-1':
示例12: unset
continue;
}
$mac_addr = $m[0];
$devices[$mac_addr]['mac'] = $mac_addr;
$devices[$mac_addr]['ip'] = $ip_addr_parts;
}
unset($out);
kSort($devices);
$c = 0;
foreach ($devices as $mac_addr => $device) {
echo '<tr class="', $c % 2 === 0 ? 'odd' : 'even', '" height="25">', "\n";
//echo '<td><code>', $device['mac'] ,'</code></td>' ,"\n";
echo '<td style="vertical-align:middle; padding-top:0.3em;"><small><code>', $device['mac'], '</code></small></td>', "\n";
echo '<td style="vertical-align:middle;">';
for ($i = 1; $i <= 4; ++$i) {
$device['ip'][$i] = lTrim($device['ip'][$i], '0');
if ($device['ip'][$i] == '') {
$device['ip'][$i] = '0';
}
/*
echo str_replace(' ', ' ', str_pad($device['ip'][$i], 3, ' ', STR_PAD_LEFT));
if ($i < 4) echo '.';
*/
}
$device['ip'][0] = $device['ip'][1] . '.' . $device['ip'][2] . '.' . $device['ip'][3] . '.' . $device['ip'][4];
echo $device['ip'][0];
echo '</td>', "\n";
$phone_type = mac_addr_to_phone_type($device['mac']);
echo '<td style="vertical-align:middle;">', $phone_type['title'], '</td>', "\n";
$can_take_over = $phone_type['key'] != '';
/*
示例13: lTrim
}
if ($height < 50) {
$height = 180;
}
$padt = 12;
$padb = 22;
$padl = 40;
$padr = 14;
$cw = $width - $padl - $padr;
$ch = $height - $padt - $padb;
$fr_y = (int) lTrim(@$_REQUEST['fy'], '0-');
$fr_m = (int) lTrim(@$_REQUEST['fm'], '0-');
$fr_d = (int) lTrim(@$_REQUEST['fd'], '0-');
$to_y = (int) lTrim(@$_REQUEST['ty'], '0-');
$to_m = (int) lTrim(@$_REQUEST['tm'], '0-');
$to_d = (int) lTrim(@$_REQUEST['td'], '0-');
$fr = mkTime(0, 0, 0, $fr_m, $fr_d, $fr_y);
$to = mkTime(23, 59, 59, $to_m, $to_d, $to_y);
if ($to < $fr) {
$tmp = $fr;
$fr = $to;
$to = $tmp;
}
$time_range = $to - $fr;
$time_range_days = $time_range / (60 * 60 * 24);
if ($time_range_days <= 2) {
$xtstr = '+1 hours';
$xdfmt = 'H';
} elseif ($time_range_days <= 31) {
$xtstr = '+1 days';
$xdfmt = 'j';
示例14: asort
$res[] = $rt;
}
asort($res);
foreach ($res as $r) {
echo '<tr class="', ++$i % 2 ? 'odd' : 'even', '">', "\n";
echo '<td class="r">', htmlEnt($r['target']), '</td>', "\n";
if ($edit == $r['target']) {
echo '<td class="c">';
$hf = (int) lTrim(@$r['hour'], '0-');
if ($hf < 0) {
$hf = 0;
} elseif ($hf > 23) {
$hf = 23;
}
$hf = str_pad($hf, 2, '0', STR_PAD_LEFT);
$mf = (int) lTrim(@$r['minute'], '0-');
if ($mf < 0) {
$mf = 0;
} elseif ($mf > 59) {
$mf = 59;
}
$mf = str_pad($mf, 2, '0', STR_PAD_LEFT);
echo '<span class="nobr">';
echo '<input type="text" name="add_hour" value="', $hf, '" size="2" maxlength="2" class="r" />:';
echo '<input type="text" name="add_minute" value="', $mf, '" size="2" maxlength="2" class="r" />';
echo '</span> ', "\n";
echo '</td>', "\n";
echo '<td>', "\n";
echo '<button type="submit" title="', __('Speichern'), '" class="plain">';
echo '<img alt="', __('Speichern'), '" src="', GS_URL_PATH, 'crystal-svg/16/act/filesave.png" />';
echo '</button>', "\n";
示例15: psetting
//setting('fkey', $key_idx, $key_def['function'] .' '. $key_def['data'], array('context'=>'active'));
# Keys on Phone
if ($key_idx >= 1 && $key_idx <= 10) {
psetting('memory' . $key_idx . '|path', '/yealink/config/vpPhone/vpPhone.ini');
psetting('memory' . $key_idx . '|Line', '0');
psetting('memory' . $key_idx . '|Value', $key_def['data']);
psetting('memory' . $key_idx . '|DKtype', subStr($key_def['function'], 1));
# for BLF
if (subStr($key_def['function'], 1) == 16) {
psetting('memory' . $key_idx . '|type', 'blf');
psetting('memory' . $key_idx . '|PickupValue', '*81*' . $key_def['data']);
}
}
# Keys on Expansion Modul
if ($key_idx >= 100) {
$key_tmp = (int) lTrim(subStr($key_idx, 1), '0');
psetting('Key' . $key_tmp . '|path', '/yealink/config/vpPhone/Ext38_0000000000000' . subStr($key_idx, 0, 1) . '.cfg');
psetting('Key' . $key_tmp . '|Line', '0');
psetting('Key' . $key_tmp . '|Value', $key_def['data']);
psetting('Key' . $key_tmp . '|DKtype', subStr($key_def['function'], 1));
# for BLF
if (subStr($key_def['function'], 1) == 16) {
psetting('Key' . $key_tmp . '|type', 'blf');
psetting('Key' . $key_tmp . '|PickupValue', '*81*' . $key_def['data']);
}
}
}
}
# XML Browser for Phonebook on Line Key 2
psetting('memory12|path', '/yealink/config/vpPhone/vpPhone.ini');
psetting('memory12|Value', $prov_url_tiptel . 'pb.php?u=' . $user_ext);