2010年9月13日 星期一

PHP Html 轉成陣列(array)

=========標題========
PHP Html 轉成陣列(array)





PHP html array
PHP html to array
php html 轉 array
========HTML========
<html id ="headmenu"><head><meta id="d" /><meta /><head/></html><div id ="headmenu">3<p>sd</p><p>sd</p>bb</div>

========結果=========
array(2) {
[0]=>
array(4) {
["tag"]=>
string(6) ""
["id"]=>
string(8) "headmenu"
["text"]=>
string(0) ""
["next"]=>
array(1) {
[0]=>
array(3) {
["tag"]=>
string(6) ""
["text"]=>
string(0) ""
["next"]=>
array(2) {
[0]=>
array(2) {
["tag"]=>
string(6) ""
["id"]=>
string(1) "d"
}
[1]=>
array(1) {
["tag"]=>
string(6) ""
}
}
}
}
}
[1]=>
array(4) {
["tag"]=>
string(5) "


"
["id"]=>
string(8) "headmenu"
["text"]=>
string(3) "3bb"
["next"]=>
array(2) {
[0]=>
array(3) {
["tag"]=>
string(3) ""
["text"]=>
string(2) "sd"
["next"]=>
array(0) {
}
}
[1]=>
array(3) {
["tag"]=>
string(3) ""
["text"]=>
string(2) "sd"
["next"]=>
array(0) {
}
}
}
}
}
========程式=========
function c2a($c){
  $t="";$re = array();$n=count($re);
  $nset=0;
  $ca=explode("<",$c);
  for($i=0;$i
   if($i>0){
    $ca[$i] = explode(">",$ca[$i]);
    
    $ck = $this->c2i($ca[$i][0]);
    if(!strstr($ca[$i][0],"/")){
     $nset++;
     if($this->taginfo($ck["tag"])){
      $nset--;
      if($nset==0){
       $n=count($re);
       $re[$n]=$this->c2i($ca[$i][0]);
       $n++;
      }else{
       $t .= "<".$ca[$i][0].">";
      }
     }else{
      if($nset==1){
       //echo "a("."<".$ca[$i][0].">".")";
       $n=count($re);
       $re[$n]=$this->c2i($ca[$i][0]);
       $re[$n]["text"] = $ca[$i][1];       
      }else{
       //echo "b("."<".$ca[$i][0].">".")";
       $t .= "<".$ca[$i][0].">".$ca[$i][1];       
      }
     }
    }else{
     $nset--;
     if($this->taginfo($ck["tag"])){
      $nset++;
      if($nset==0){
       $n=count($re);
       $re[$n]=$this->c2i($ca[$i][0]);
       $n++;
      }else{
       $t .= "<".$ca[$i][0].">";
      }
     }else{
      if($nset==0){
       //echo "c("."<".$ca[$i][0].">".")";     
       $re[$n]["next"] = $this->c2a($t);
       $t="";$n=count($re);     
      }else{
       //echo "d("."<".$ca[$i][0].">".")";
       if(!isset($re[$n]["text"]))$re[$n]["text"]= $ca[$i][1]; else $re[$n]["text"].= $ca[$i][1];
       $t .= "<".$ca[$i][0].">".$ca[$i][1];       
      }
     }
    } 
   }
  }
  return $re;  
 }

====================================
目前沒有常用到此FUNCTION
但知道一定有一些問題
請大家如果有發現問題,請告訴我,我會修正

2010年9月8日 星期三

PHP EREG 正規表達示 判斷EMAIL

PHP判斷EMAIL 正規表達示

function validateMail($mail) { 
  if($mail !== "") { 
    if(ereg("^[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[@]{1}[-A-Za-z0-9_]+[-A-Za-z0-9_.]*[.]{1}[A-Za-z]{2,5}$", $mail)) { 
      return true; 
    } else { 
      return false; 
    } 
  } else { 
    return false; 
  } 
} 

2010年7月10日 星期六

666forum免費論壇申請之去除論壇廣告測試

666forum免費論壇申請-----去除論壇廣告測試------

前一篇,已經有找到兩個感覺有不少人推薦的免費論壇

當然找論壇當然就是為了架論壇摟!!

小弟我就架架看了@@顆顆

第一個就發現模板很好看也有很多可選

好像也能擴充(尚未實際用過)

速度也不錯

整體上感覺很不錯的

不過不過

重點,他有廣告(好像其他的也有= =")

於是小弟我就找阿找阿

想看看怎麼把廣告移除

於是乎就腦子動到javascript上面了

然後第一個當然就是用display:none;

結果失敗...

.測試過程...
.
.

就發現了一個可以把廣告拿掉的方法(算是吧!!)

把廣告換成文字...就是這樣

======YES======

接下來就是要找到底哪邊可以放這段javascript 程式碼摟!!

.尋找過程...
.
.

發現一個"免強"還不錯的地方...

就是在 "基本設置>設置>討論區描述 " 的地方可以加入語法


save image

就這樣就把廣告移除了 ,說起來還頗簡單的 = ="

至於javascript語法也很簡單...





嘿嘿!!甚至應該還能換成自己的廣告...(ㄒㄒ)


==============實際測試=================
原始:有廣告
save image


增加JS後: 移除廣告

save image


===============PS=====================
最後發現他的廣告其實還是會讀到

不過讀完馬上就被換成自己設定的文字
(小於一秒鐘)

這樣其實也不錯啦^^,互利麻~!顆顆
(也許可以找到更上游的地方,應該可以連讀都沒讀就換掉)


(這個論壇可以,其他的應該也可以

主要就是找到那個廣告的ID

然後再一個可以寫JS的地方

也可以所有頁面都讀到的地方)

===============END====================