如何&从URL地址中删除一个符号使用php常规?例如:http://www.google.com/search?hl=en&q=php
离开&并得到:http://www.google.com/search?hl=enq=php
谢谢
我想通过href发布一些值.但是,我不喜欢使用像这样的链接index.php?id=value.还有其他方法吗?
我想张贴test1和test2.
<div id="div1">
<li><a href="index.php">test1</a></li>
<li><a href="index.php">test2</a></li>
</div>
<div id="div2">this is a <? $_POST["name"]; ?>, just a test.</div>
Run Code Online (Sandbox Code Playgroud) <?php
require_once("simple_html_dom.php");
$str = '<div class="content"><span>text1</span><span>text2</span><span>text3</span><span>text4</span><span>text5</span><span>text6</span><span>text7</span><span>text8</span><span>text9</span><span>text10</span><span>text11</span><span>text12</span><span>text13</span><span>text14</span><span>text15</span><span>text16</span></div>';
$dom = html_entity_decode($str);
$html = str_get_html($dom);
foreach($html->find('span') as $e)
echo $e . '<br>';
?>
Run Code Online (Sandbox Code Playgroud)
在此代码中,它可以回显一行中的每个跨度.但是我如何编写它以便3个结果将合并为一个foreach?
我需要一个结果:
text1 text2 text3 <br />
text4 text5 text6 <br />
text7 text8 text9 <br />
text10 text11 text12 <br />
text13 text14 text15 <br />
text16
Run Code Online (Sandbox Code Playgroud) 我想设置12:03:37每天运行一个带有cron的文件.如何设置set cron以在几秒钟内准确运行文件?
如果category='art'且image字段中没有值,我想查询前20个结果.
我可以写这样的SQL查询吗?
SELECT image,date,category FROM imagecart WHERE category='art' AND image != '' Order By date DESC LIMIT 0,20
Run Code Online (Sandbox Code Playgroud) 我想将 php 变量传递$aa给类函数。我读过php.net上的一些文章
,但还是不太明白。谁能帮我将变量放入这个类中?谢谢。
$aa='some word';
class Action {
private $_objXML;
private $_arrMessages = array();
public function __construct() {
$this->_objXML = simplexml_load_file($aa.'.xml');
}
}
Run Code Online (Sandbox Code Playgroud) 我从php foreach插入一些数据.当数据插入时,我确定数据是否已存在于2个表中?如果没有,插入,否则跳.
但是在这个过程中,我如何知道每个项目数据是否已被插入?
{
//some foreach process get $title, $name, $date
mysql_query("INSERT INTO table1 (title,name,date) SELECT '".$title."','".$name."','".$date."' FROM dual WHERE not exists (SELECT title FROM table1 WHERE table1.title = '".$title."') AND NOT EXISTS (SELECT title FROM table2 WHERE table2.title = '".$title."')");
//I want to add some judge like this:
//if this item insert {
//do some stuff;
//} else {
//do some stuff;
//}
}
Run Code Online (Sandbox Code Playgroud) 如何确定除以8的数字是否为整数?
例如:
32 % 8 = 4, it is an integer.
25 % 8 = 3.125, it is not an integer.
Run Code Online (Sandbox Code Playgroud)
我需要一个像以下工作代码:
if ($str % 8 == integer){
// continue working
}
Run Code Online (Sandbox Code Playgroud) jquery如何将addClass添加到所有的ul.menu li:first.selection?
这里的演示代码:
我需要的menu1 menu4 menu7,所有first li的ul.menu改变字体颜色为红色.
谢谢.
我有一个包含200多个项目的大型JSON文件.其中有5组数据.每组至少有30个项目.我使用它来区分它们"p" tag,就像"p":"1","p":"2","p":"3","p":"4","p":"5"在json数据中一样.现在我想从每个组中获取2个项目,并且总计10个项目随机订单.
为了便于解释,我设置了一些简单的数据,如下所示."p":"1"在其组中有4个项目,"p":"2"在其组中有4个项目.
现在如何使用随机订单来获取2个项目"p":"1"和2个项目"p":"2"?
$json = <<<ETO
[
{
"a":"apple",
"p":"1"
},
{
"a":"orange",
"p":"1"
},
{
"a":"pear",
"p":"1"
},
{
"a":"banana",
"p":"1"
},
{
"a":"Chauli",
"p":"2"
},
{
"a":"Carrot",
"p":"2"
},
{
"a":"Lettuce",
"p":"2"
},
{
"a":"Potato",
"p":"2"
}
]
ETO;
$data = json_decode($json);
shuffle($data);// some shuffle like this is very ugly...
foreach($data as $row){
$aoo = 1;
$boo = 1;
if($row->p==1){
echo $row->p.': '.$row->a.'<br />';
$aoo++;
if($aoo==2){
break;
}
} …Run Code Online (Sandbox Code Playgroud)