21,891
社区成员
发帖
与我相关
我的任务
分享
3.
mysql -uroot -p123456
select discription,title from TB_test where match(discription,title) against("用户输入数据");
表类型必须是MyISAM才可以。
<pre>
<?php
function q1($pStr, $pStr_begin, $pStr_end)
{
preg_match_all('/'.$pStr_begin.'(.*?)'.$pStr_end.'/',$pStr,$out);
return $out;
}
print_r(q1('11AgoodB, AbadBqqqAmanB22', 'A', 'B'));
function q2($n)
{
for ($i=1;$i<=$n*$n;$i++){
if ($i==1) {
$y = 1;
$x = intval($n/2)+1;
} else {
$y = ($oy==1)?$n:$oy-1;
$x = ($ox==$n)?1:$ox+1;
if (($oy==1&&$ox==$n)||isset($arr[$y][$x])) {
$y = $oy+1;
$x = $ox;
}
}
$oy = $y;
$ox = $x;
$arr[$y][$x] = $i;
}
$str = '';
for ($i=1;$i<=$n;$i++) {
for($j=1;$j<=$n;$j++){
$str .= "\t".$arr[$i][$j];
}
$str .= "\n";
}
return $str;
}
print_r(q2(3));
print_r(q2(5));
?>
</pre>//1、
function c($pStr, $pStr_begin, $pStr_end){
preg_match_all ("@{$pStr_begin}([^{$pStr_begin}{$pStr_end}]+)$pStr_end@iSU", $pStr, $output);
var_export($output);
}
// 2、参数说明(矩阵宽度, 矩阵填充内容)
function c($num,$str='*'){
$str = array_pad($str, $num, $str);
$str = array_pad($str, $num, $str);
var_export($str);
}
//3、最直接的就是用 Like %% / Not Like %%然后把条件And起来即可function Q1($pStr, $pStr_begin, $pStr_end) {
$offset = 0;
$output = array();
while (false !== ($p1 = strpos($pStr, $pStr_begin, $offset)) &&
false !== ($offset = $p2 = strpos($pStr, $pStr_end, $p1)) &&
$output[] = substr($pStr, ++$p1, $p2 - $p1)) {
}
return $output;
}