本文整理汇总了PHP中substring函数的典型用法代码示例。如果您正苦于以下问题:PHP substring函数的具体用法?PHP substring怎么用?PHP substring使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了substring函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_action
public function update_action()
{
if (!$this->input->is_ajax_request()) {
show_404();
}
$name = $this->input->post('name', true);
$link = $this->input->post('link', true);
$info = $this->input->post('info', true);
$sort = (int) $this->input->post('sort');
$data['name'] = trim($name);
$data['link'] = $link;
$data['info'] = substring(format_content($info), 240);
$data['sort'] = $sort > 255 ? 255 : $sort;
if (!$data['name'] or !$data['link']) {
JSON('error', '对不起,请填写必填字段!');
}
if (!is_url($data['link'])) {
JSON('error', '请填写有效的网站 URL 地址!');
}
$lid = (int) $this->input->post('lid');
$this->db->update('link', $data, array('lid' => $lid));
if ($this->db->affected_rows()) {
JSON('success', '恭喜,链接已更新成功!');
} else {
JSON('error', '对不起,链接没有更新名更新失败!');
}
}
示例2: parse_path
public function parse_path($file)
{
if (is_string($file)) {
if (strlen($file[0]) > 0 && $file[0] == '/') {
$file = substring($file, 1);
}
return $this->get_loader_url() . $file;
}
return false;
}
示例3: __construct
/**
* 构造函数
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
$p = (int) $this->input->get('p');
$k = (string) $this->input->get('k', true);
$this->_page = $p === 0 ? 1 : $p;
$this->_keys = $this->_safereplace(substring(trim($k), 32, false));
if (empty($this->_keys)) {
show_404();
}
}
示例4: combine
public function combine($form1, $form2, $act2)
{
if ($act2 == null) {
// Ex.: _k + paaq > _paaq
return substring($form1, 0, strlen($form1) - 1) . $form2;
} else {
$act2Type = -1;
$act2Type = $act2->type();
if ($act2Type == Action::NULLACTION) {
// Ex.: _k + paaq > _paaq
return substr($form1, 0, strlen($form1) - 1) . $form2;
} elseif ($act2Type == Action::DELETION) {
// Ex.: _VVk + ilitaq > _Vilitaq
return substr($form1, 0, strlen($form1) - 2) . $form2;
} elseif ($act2Type == Action::SELFDECAPITATION) {
// Ex.: _VVk + uqqaq > _VVqqaq
return substr($form1, 0, strlen($form1) - 1) . substr($form2, 1);
} elseif ($act2Type == Action::INSERTION) {
// Ex.: _VVq + u > _VVngu
return substr($form1, 0, strlen($form1) - 1) . $act2->getInsert() . $form2;
} elseif ($act2Type == Action::SPECIFICDELETION) {
// Ex.: _Vaq + it > _Vit
return substr($form1, 0, strlen($form1) - 2) . $form2;
} else {
return "";
}
}
}
示例5: update_action
public function update_action()
{
if (!$this->input->is_ajax_request()) {
show_404();
}
$cid = (int) $this->input->post('cid');
if ($cid === 0) {
JSON('error', '对不起,更新分类提交失败!');
}
$name = $this->input->post('name', true);
$link = $this->input->post('link', true);
$keyword = $this->input->post('keyword', true);
$description = $this->input->post('description', true);
$sort = (int) $this->input->post('sort');
$data['name'] = trim($name);
$data['link'] = url_title($link, 'underscore', true);
$data['sort'] = $sort > 255 ? 255 : $sort;
$data['keyword'] = format_keyword($keyword);
$data['description'] = substring(format_content($description), 240);
if (!$data['name'] or !$data['link']) {
JSON('error', '对不起,请填写必填字段!');
}
if ($this->category_model->get_info(array('cid !=' => $cid, 'name' => $name))) {
JSON('error', '对不起,分类名称已经存在!');
}
if ($this->category_model->get_info(array('cid !=' => $cid, 'link' => $link))) {
JSON('error', '对不起,分类链接名称已经存在!');
}
$this->db->update('category', $data, array('cid' => $cid));
if ($this->db->affected_rows()) {
JSON('success', '恭喜,分类 ' . $data['name'] . ' 更新成功!');
} else {
JSON('error', '对不起,分类没有更新或更新失败!');
}
}
示例6: substring
</td>
<td><?php
echo $item['command'];
?>
</td>
<td><?php
echo $item['time'];
?>
</td>
<td><?php
echo $item['status'];
?>
</td>
<td>
<div class="message_head"><span class="message_icon"><i class="icon-plus"></i></span><cite><?php
echo substring($item['info'], 0, 40);
?>
:</cite></div>
<div class="message_body" style="width: 300px;">
<pre><span style="color: blue;"><?php
echo $item['info'];
?>
</span></pre>
</div>
</td>
<td><?php
echo $item['host'];
?>
:<?php
echo $item['port'];
?>
示例7: foreach
if (!empty($datalist)) {
?>
<?php
foreach ($datalist as $item) {
?>
<tr style="font-size: 12px;">
<td><a href="<?php
echo site_url('slowquery/detail/' . $item['checksum'] . '/' . $setval['server_id']);
?>
" target="_blank" title="点击进入详情"><?php
echo $item['checksum'];
?>
</a></td>
<td>
<div class="message_head"><span class="message_icon"><i class="icon-plus"></i></span><cite><?php
echo substring($item['fingerprint'], 0, 40);
?>
:</cite></div>
<div class="message_body" style="width: 300px;">
<pre><span style="color: blue;"><?php
echo $item['fingerprint'];
?>
</span></pre>
</div>
<td><?php
echo $item['last_seen'];
?>
</td>
<td><?php
echo $item['ts_cnt'];
示例8: wee_process_weeSet
function wee_process_weeSet($keyval, $wee)
{
$key = trim(substring($keyval, 0, strpos($keyval, '=')));
$val = trim(substring($keyval, strpos($keyval, '=') + 1, 999));
$wee[$key] = $val;
}
示例9: View
//.........这里部分代码省略.........
}
?>
>程序反馈影片无法播放</option>
<option value="1" <?php
if ($i == "1") {
echo "selected";
}
?>
>用户反馈影片无法播放</option>
<option value="2" <?php
if ($i == "2") {
echo "selected";
}
?>
>用户反馈影片播放不流畅</option>
<option value="3" <?php
if ($i == "3") {
echo "selected";
}
?>
>用户反馈影片加载比较慢</option>
<option value="4" <?php
if ($i == "4") {
echo "selected";
}
?>
>用户反馈影片不能下载</option>
<option value="5" <?php
if ($i == "5") {
echo "selected";
}
?>
>用户反馈观看影片时出现闪退</option>
<option value="6" <?php
if ($i == "6") {
echo "selected";
}
?>
>用户反馈画质不清晰</option>
<option value="7" <?php
if ($i == "7") {
echo "selected";
}
?>
>用户反馈音画不同步</option>
<option value="8" <?php
if ($i == "8") {
echo "selected";
}
?>
>用户反馈其它(用户自己填写,可不填)</option>
<option value="10" <?php
if ($i == "10") {
echo "selected";
}
?>
>程序反馈视频地址失效</option>
</select></td>
<td><?php
echo $db->getOne("select count(*) as count from tbl_video_feedback where feedback_type like '%" . $i . "%' and prod_id=" . $d_id);
?>
</td>
</tr>
<?php
}
?>
</table>
<table class="admin_vod_feedback tb" width="50%">
<tr>
<td colspan="3">反馈类别:其它(用户自己填写,可不填)</td>
</tr>
<tr>
<td width="5%"></td>
<td>反馈时间</td>
<td>反馈内容</td>
</tr>
<?php
$rs = $db->query("select * from tbl_video_feedback where feedback_type like '%8%' and prod_id=" . $d_id);
while ($row = $db->fetch_array($rs)) {
?>
<tr><td width="5%"></td>
<td width="40%"><?php
echo isToday($row["create_date"]);
?>
</td>
<td><?php
echo substring($row["feedback_memo"], 20);
?>
</td>
</tr>
<?php
}
unset($rs);
?>
</table>
<?php
echo '</body>
</html>';
}
示例10: showErr
} else {
if (substring($path, 11) != '../template' || count(explode('../', $path)) > 2) {
showErr('System', '非法目录请求');
return;
}
$extarr = array('.html', '.htm', '.js', '.xml', '.wml');
if (!in_array($suffix, $extarr)) {
$suffix = '.html';
}
fwrite(fopen($path . '/' . $filename . $suffix, 'wb'), $filecontent);
}
showMsg('文件内容保存完毕', '');
} elseif ($method == 'del') {
$file = $p['file'];
$file = str_replace('\\', '/', $file);
if (substring($file, 11) != '../template' || count(explode('../', $file)) > 2) {
showErr('System', '非法目录请求');
return;
}
if (file_exists($file)) {
unlink($file);
}
redirect(getReferer());
} elseif ($method == 'ads') {
$path = '../template/' . $MAC['site']['templatedir'] . '/' . $MAC['site']['adsdir'] . '/';
if (!is_dir($path)) {
showErr('System', '未找到指定系统路径:' . $path);
return;
}
$plt->set_file('main', $ac . '_' . $method . '.html');
$fcount = 0;
示例11: MovieInflow
//.........这里部分代码省略.........
$rs_collect2 = $db->query($sql2);
$mrowurl = $db->fetch_array($rs_collect2);
//插入新数据开始
if (isN($rowvod["d_id"]) || be("post", "CCTV") == "1") {
$flag = true;
$d_pic = replaceStr($row["m_pic"], "'", "''");
$d_pic_ipad = replaceStr($row["d_pic_ipad"], "'", "''");
$d_addtime = date('Y-m-d H:i:s', time());
$d_year = $row["m_year"];
if (isN($d_year) || $d_year === '未知') {
$d_year = '其他';
}
$d_content = $row["m_content"];
$d_hits = $row["m_hits"];
$d_area = $row["m_area"];
if (isN($d_area) || $d_area === '未知') {
$d_area = '其他';
}
$d_remarks = $row["m_remarks"];
if (!isNum($d_remarks)) {
$d_remarks = '';
}
$d_state = $row["m_state"];
$d_starring = $row["m_starring"];
$d_directed = $row["m_directed"];
$duraning = $row["duraning"];
$d_name = $title;
$typeName = $row["m_type"];
if (isN($typeName) || $typeName === '未知') {
$typeName = '其他';
}
$d_enname = hanzi2pinyin($d_name);
$d_capital_name = Hanzi2PinYin_Captial($d_name);
$d_letter = strtoupper(substring($d_enname, 1));
if ($row["m_typeid"] > 0) {
$d_type = $row["m_typeid"];
} else {
if (!isN($row["m_type"])) {
$sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
$rowtype = $db->getRow($sql);
if ($rowtype) {
$d_type = $rowtype["t_id"];
}
unset($rowtype);
}
}
if (!($d_type === '1' || $d_type === 1)) {
$duraning = '';
}
if (isN($mrowurl["iso_video_url"]) && isN($mrowurl["android_vedio_url"])) {
//判断下载地址 无
if ($row["m_playfrom"] == "qq" || $row["m_playfrom"] == "pptv") {
$strSet .= "can_search_device='iPad,iphone,apad,aphone,web' , ";
//入库 不勾tv.vender
echo "qq和pptv播放源直接入库 视频名称: \"" . $title . "\" 播放源: " . $row["m_playfrom"] . "\";";
}
} else {
// 判断下载地址 有
if ($row["m_playfrom"] == "youku") {
// 入库数据是优酷
$strSet .= "can_search_device='TV,Vendor' , ";
//入库 勾选tv vendor
} else {
$strSet .= "can_search_device='TV,iPad,iphone,apad,aphone,web,Vendor' , ";
//入库 全部勾选
}
示例12: substring
exit;
// course information
$output = substring($output, "<div id=\"content\">", "<div id=\"footer\">");
$courseInfo = substring($output, "<table width=100% border=0 cellpadding=1 cellspacing=1>", "<!-- Display ONLY if not EMBA -->");
$courseInfo = substring($courseInfo, "<table>", "</table>");
$fCourseInfo = validateHTML($courseInfo);
printCourseInfo($fCourseInfo);
// grades information
$str = "<!-- Display ONLY if not EMBA -->";
$gradesInfo = substr($output, stripos($output, $str) + strlen($str));
$fGradesInfo = validateHTML(substring($gradesInfo, "<table border=0 cellpadding=1 cellspacing=1>", $str));
$fGradesInfo = substring($fGradesInfo, "<table>", "</table>");
printGradesInfo($fGradesInfo);
// detailed information
$detailed = substring($gradesInfo, "<table border=0 cellpadding=1 cellspacing=0>", "<p><br>");
$detailed = substring($detailed, "<table>", "</table>");
$fDetailed = validateHTML($detailed);
printDetailed($fDetailed);
curl_close($ch);
function printCourseInfo($xmlString)
{
$xml = new SimpleXMLELement($xmlString);
print "<p>";
$i = 0;
foreach ($xml->tr as $tr) {
$j = 0;
foreach ($tr->td as $td) {
$class = $j == 0 ? "title" : "value";
if ($i == 3) {
$a = $td->a;
if ($a != "") {
示例13: MovieInflow
function MovieInflow($sql_collect, $MovieNumW)
{
global $db;
?>
<table class=tb>
<tr>
<td colspan="2" align="center"> 入 库 状 态 </td>
<div id="refreshlentext" style="background:#006600"></div>
</td>
</tr>
<tr>
<td colspan="2" align="center"><span id="storagetext">正 在 入 库...</span></td>
</tr>
</table>
<?php
$iscover = be("iscover", "get");
$rs = $db->query($sql_collect);
$rscount = $db->num_rows($rs);
// var_dump($rscount);
if ($rscount == 0) {
echo "<script>alert('没有可入库的数据!'); location.href='collect_vod.php';</script>";
exit;
}
if ($rscount > 10000) {
$rscount = 1000;
} elseif ($rscount > 5000) {
$rscount = 500;
} elseif ($rscount > 1000) {
$rscount = 100;
} else {
$rscount = 10;
}
while ($row = $db->fetch_array($rs)) {
if (!(isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && strlen(trim($row["m_playfrom"])) > 0)) {
continue;
}
if (isset($row["m_playfrom"]) && !is_null($row["m_playfrom"]) && ($row["m_playfrom"] === 'cntv' || $row["m_playfrom"] === 'wasu' || $row["m_playfrom"] === 'kankan' || $row["m_playfrom"] === 'tudou' || $row["m_playfrom"] === '')) {
continue;
}
$flag = false;
$title = $row["m_name"];
$d_type = $row["m_typeid"];
$title = replaceStr($title, "<", "<<");
$title = replaceStr($title, ">", ">>");
$testUrl = $row["m_urltest"];
$year = $row['m_year'];
$title = replaceStr($title, "'", "''");
$strSet = "";
$sql = "SELECT * FROM {pre}vod WHERE d_name = '" . $title . "' and d_type = '" . $d_type . "' ";
$rowvod = $db->getRow($sql);
if (!isN($rowvod["d_status"]) && ($rowvod["d_status"] === 1 || $rowvod["d_status"] === '1')) {
var_dump($title . " is locked");
continue;
}
//插入新数据开始
if (isN($rowvod["d_id"]) || be("post", "CCTV") == "1") {
$flag = true;
$d_pic = replaceStr($row["m_pic"], "'", "''");
$d_addtime = date('Y-m-d H:i:s', time());
$d_year = $row["m_year"];
$d_content = $row["m_content"];
$d_hits = $row["m_hits"];
$d_area = $row["m_area"];
$d_language = $row["m_language"];
$d_remarks = $row["m_remarks"];
$d_state = $row["m_state"];
$d_starring = $row["m_starring"];
$d_directed = $row["m_directed"];
$d_name = $title;
$d_enname = hanzi2pinyin($d_name);
if (isN($d_letter)) {
$d_letter = strtoupper(substring($d_enname, 1));
}
if ($row["m_typeid"] > 0) {
$d_type = $row["m_typeid"];
} else {
if (!isN($row["m_type"])) {
$sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
$rowtype = $db->getRow($sql);
if ($rowtype) {
$d_type = $rowtype["t_id"];
}
unset($rowtype);
}
}
$sql = "insert {pre}vod (d_type_name,d_type,d_pic,d_addtime,d_time,d_year,d_content,d_hits,d_area,d_language,d_name,d_enname,d_starring,d_directed,d_state,d_remarks) values('" . $row["m_type"] . "','" . $d_type . "','" . $d_pic . "','" . $d_addtime . "','" . $d_addtime . "','" . $d_year . "','" . $d_content . "','" . $d_hits . "','" . $d_area . "','" . $d_language . "','" . $d_name . "','" . $d_enname . "','" . $d_starring . "','" . $d_directed . "','" . $d_state . "','" . $d_remarks . "') ";
$db->query($sql);
$did = $db->insert_id();
} else {
//同名不处理, 如果是电影也不更新
if (be("post", "CCTV") == "3" || $d_type === '1' || $d_type == 1) {
//var_dump("dd");
continue;
}
//更新数据开始
if ($row["m_typeid"] > 0) {
$d_type = $row["m_typeid"];
} else {
if (!isN($row["m_type"])) {
$sql = "select * from {pre}vod_type where t_name like '%" . $row["m_type"] . "%' ";
//.........这里部分代码省略.........
示例14: substring
?>
</td>
<td><?php
echo substring($item['Query_time_max'], 0, 5);
?>
</td>
<td><?php
echo substring($item['Lock_time_sum'], 0, 6);
?>
</td>
<td><?php
echo substring($item['Lock_time_min'], 0, 7);
?>
</td>
<td><?php
echo substring($item['Lock_time_max'], 0, 7);
?>
</td>
</tr>
<?php
}
} else {
?>
<tr>
<td colspan="10">
<font color="red"><?php
echo $this->lang->line('no_record');
?>
</font>
</td>
</tr>
示例15: intval
$d_state = intval($array3[$xn_d_state][$key]);
$d_type = $xt == '0' ? $array3[$xn_d_type][$key] : $flag . $array3[$xn_d_type][$key];
$d_type = intval($bindcache[$d_type]);
$d_starring = htmlspecialchars_decode($array3[$xn_d_starring][$key]);
$d_directed = htmlspecialchars_decode($array3[$xn_d_directed][$key]);
$d_pic = $array3[$xn_d_pic][$key];
$d_time = $array3[$xn_d_time][$key];
$d_year = intval($array3[$xn_d_year][$key]);
$d_area = $array3[$xn_d_area][$key];
$d_lang = $array3[$xn_d_lang][$key];
$d_content = htmlspecialchars_decode($array3[$xn_d_content][$key]);
$d_playurls = htmlspecialchars_decode($array3[$xn_d_urls][$key]);
$d_playurls = str_replace("'", "''", $d_playurls);
preg_match_all($xn_url, $d_playurls, $array4);
$d_enname = Hanzi2PinYin($d_name);
$d_letter = strtoupper(substring($d_enname, 1));
$d_addtime = time();
$d_time = $d_addtime;
$d_hitstime = "";
$d_hits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']);
$d_dayhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']);
$d_weekhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']);
$d_monthhits = rand($MAC['collect']['vod']['hitsstart'], $MAC['collect']['vod']['hitsend']);
$d_scorenum = rand(1, 500);
$d_scoreall = $d_scorenum * rand(1, 10);
$d_score = round($d_scoreall / $d_scorenum, 1);
$d_hide = $MAC['collect']['vod']['hide'];
if ($MAC['collect']['vod']['psernd'] == 1) {
$d_content = repPseRnd('vod', $d_content, $i);
}
if ($MAC['collect']['vod']['psesyn'] == 1) {