本文整理匯總了PHP中utils::removehtml方法的典型用法代碼示例。如果您正苦於以下問題:PHP utils::removehtml方法的具體用法?PHP utils::removehtml怎麽用?PHP utils::removehtml使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類utils
的用法示例。
在下文中一共展示了utils::removehtml方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: import_data
public static function import_data(array $arr_files = array(), $tableName)
{
$qas = new qas();
$import_count = 0;
foreach ($arr_files as $txt_path) {
$d_array = parse_ini_file($txt_path, true);
foreach ($d_array as $k => $v) {
$qid = intval($v['id']);
$title = $v['title'];
$content = str_replace("病情描述:", "", $v['content']);
//科室:
$department = "";
if (isset($v['department']) && !empty($v['department'])) {
$departmentArr = explode(" → ", $v['department']);
//隻獲取 2 級科室的信息,如果是 3 級科室的話,去掉最後一級的 疾病信息
if (isset($departmentArr[2])) {
unset($departmentArr[2]);
}
$department = implode(",", $departmentArr);
}
//性別年齡
$age = '0歲';
$sex = '';
$sexage = $v['sexage'];
if (isset($sexage) && !empty(trim($sexage))) {
$sexageArr = explode(" | ", $sexage);
if (isset($sexageArr) && !empty($sexageArr)) {
$arr = $sexageArr;
$sex = empty($arr) ? '' : isset($arr[0]) ? trim($arr[0]) : '';
$age = empty($arr) ? '0歲' : isset($arr[1]) ? trim($arr[1]) : '0歲';
}
}
$createtime = empty($v['createtime']) ? time() : strtotime($v['createtime']);
$reply = $v['reply'];
$length = strlen($reply);
if (strstr($reply, "<p>")) {
if (strpos($reply, "<p>") != 0) {
$reply = str_pad($reply, $length + 3, "<p>", STR_PAD_LEFT);
}
} else {
$reply = str_pad($reply, $length + 3, "<p>", STR_PAD_LEFT);
}
$matches = array();
preg_match_all("'<p>([\\s\\S]*?)</p>'i", $reply, $matches);
$fst_matches = empty($matches) ? null : $matches[0];
$reply1 = isset($fst_matches[0]) ? utils::removehtml($fst_matches[0]) : '';
//$reply1 = self::dealReply($reply1);
$reply2 = isset($fst_matches[1]) ? utils::removehtml($fst_matches[1]) : '';
// $reply2 = self::dealReply($reply2);
$result = $qas->import_data($qid, $title, $content, $createtime, $reply1, $reply2, $department, $age, $sex, $tableName);
if ($result) {
$import_count++;
}
}
}
return $import_count;
}
示例2: run
public function run()
{
echo "當前執行的線程是:" . $this->flag . " 個!";
$d_array = $this->data;
$import_count = 0;
foreach ($d_array as $k => $v) {
$qid = intval($v['id']);
$title = $v['title'];
$content = $v['content'];
$department = "";
if (isset($v['department']) && !empty($v['department'])) {
$departmentArr = explode(" → ", $v['department']);
//刪除頭和尾的數據
array_shift($departmentArr);
array_shift($departmentArr);
array_pop($departmentArr);
$department = implode(",", $departmentArr);
}
//性別年齡
$age = '0歲';
$sex = '';
$sexage = $v['sexage'];
if (isset($sexage) && !empty(trim($sexage))) {
$sexageArr = explode(" | ", $sexage);
if (isset($sexageArr) && !empty($sexageArr)) {
$arr = $sexageArr;
$sex = empty($arr) ? '' : isset($arr[0]) ? trim($arr[0]) : '';
$age = empty($arr) ? '0歲' : isset($arr[1]) ? trim($arr[1]) : '0歲';
}
}
$createtime = empty($v['createtime']) ? time() : strtotime($v['createtime']);
$reply = $v['reply'];
$length = strlen($reply);
if (strstr($reply, "<p>")) {
if (strpos($reply, "<p>") != 0) {
$reply = str_pad($reply, $length + 3, "<p>", STR_PAD_LEFT);
}
} else {
$reply = str_pad($reply, $length + 3, "<p>", STR_PAD_LEFT);
}
$matches = array();
preg_match_all("'<p>([\\s\\S]*?)</p>'i", $reply, $matches);
$fst_matches = empty($matches) ? null : $matches[0];
$reply1 = isset($fst_matches[0]) ? utils::removehtml($fst_matches[0]) : '';
$reply1 = self::dealReply($reply1);
$reply2 = isset($fst_matches[1]) ? utils::removehtml($fst_matches[1]) : '';
$reply2 = self::dealReply($reply2);
$result = $this->qas->import_data($qid, $title, $content, $createtime, $reply1, $reply2, $department, $age, $sex);
if ($result) {
$import_count++;
}
}
$this->import_count = $import_count;
}
示例3: array
/**
* 導入采集的問答數據
*
*
$txt_path = Yii::getPathOfAlias('webroot'). "/res/120ask_list.txt";
$file_paths = array($txt_path);
$import_count = utils::import_data($file_paths);
echo sprintf('共導入%d條問題',$import_count);
echo $d_array['rs.reply3'];
*
*/
public static function import_data(array $arr_files = array(), $tableName)
{
$qas = new qas();
$seconds = 10;
$import_count = 0;
foreach ($arr_files as $txt_path) {
$d_array = parse_ini_file($txt_path, true);
foreach ($d_array as $k => $v) {
if ($k != 0 && $k % 100 == 0) {
sleep($seconds);
}
$qid = intval($v['id']);
$title = $v['title'];
$content = $v['content'];
$department = "";
if (isset($v['department']) && !empty($v['department'])) {
$departmentArr = explode(" → ", $v['department']);
//刪除頭和尾的數據
array_shift($departmentArr);
array_pop($departmentArr);
$department = implode(",", $departmentArr);
}
//性別年齡
$age = '0歲';
$sex = '';
$sexage = $v['sexage'];
if (isset($sexage) && !empty(trim($sexage))) {
$sexageArr = explode("歲", $sexage);
if (isset($sexageArr) && !empty($sexageArr)) {
$sexageVal = $sexageArr[0];
$arr = explode("|", $sexageVal);
$age = empty($arr) ? '0歲' : isset($arr[1]) ? trim($arr[1]) . '歲' : '0歲';
$sex = empty($arr) ? '' : isset($arr[0]) ? trim($arr[0]) : '';
}
}
$createtime = empty($v['createtime']) ? time() : strtotime($v['createtime']);
$reply = $v['reply'];
$matches = array();
preg_match_all("'<p>([\\s\\S]*?)</p>'i", $reply, $matches);
$fst_matches = empty($matches) ? null : $matches[0];
$reply1 = isset($fst_matches[0]) ? utils::removehtml($fst_matches[0]) : '';
$reply2 = isset($fst_matches[1]) ? utils::removehtml($fst_matches[1]) : '';
$result = $qas->import_data($qid, $title, $content, $createtime, $reply1, $reply2, $department, $age, $sex, $tableName);
if ($result) {
$import_count++;
}
}
}
return $import_count;
}