Time of Update: 2016-07-25
改進後不用再按處理前的數組的長度遍曆,直接按處理後的數組長度遍曆即可 function unique($array) { sort($array); $arraylength=count($array); $endarray=array(); for ($i=0;$i{ if ($i!="0") { $nextvalue=$array[$i-1]; }else{
Time of Update: 2016-07-25
//php當前迴圈為1,迴圈由裡到外依次遞增,break預設為1,例如跳出第2層迴圈for ($i=0;$i foreach (array(1,2,3) as $val){ foreach (array(1,2,3) as $val){ echo "1層迴圈"; break 2; //跳出第2層迴圈 } echo "2層迴圈"; }
Time of Update: 2016-07-25
class SessionToDB{ private $_path = null; private $_name = null; private $_pdo = null; private $_ip = null; private $_maxLifeTime = 0; public function __construct(PDO $pdo) {
Time of Update: 2016-07-25
function ClearHtml($content,$allowtags='') {mb_regex_encoding('UTF-8');//replace MS special characters first$search = array('/‘/u', '/’/u', '/“/u', '/”/u', '/—/u');$replace = array('\'', '\'', '"', '"', '-');$content = preg_replace($search, $replace,
Time of Update: 2016-07-25
因為mb_substr、mb_strlen太過低效,故而採用了此段代碼。 非原創,主要原理是根據UTF-8的編碼特點 0xxxxxxx 110xxxxx 10xxxxxx 1110xxxx 10xxxxxx 10xxxxxx 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx 111110xx 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 1111110x 10xxxxxx 10xxxxxx 10xxxxxx 10xxxxxx 10
Time of Update: 2016-07-25
// 輸出Excel檔案頭,可把user.csv換成你要的檔案名稱header('Content-Type: application/vnd.ms-excel');header('Content-Disposition: attachment;filename="user.csv"');header('Cache-Control: max-age=0'); // 從資料庫中擷取資料,為了節省記憶體,不要把資料一次性讀到記憶體,從控制代碼中一行一行讀即可$sql = 'select * from
Time of Update: 2016-07-25
/**讀取檔案內容至字串中,同時去除換行、行首行尾空格。 */ header("Content-type: text/html; charset=utf-8");echo preg_replace('/((\s)*(\n)+(\s)*)/i',',',file_get_contents('./file.php'));//End_php//輸出://aaaa,bbbb,cccc,dddd,eeee,ffff,gggg,hhhh,iiii,jjjj,kk kk,ll
Time of Update: 2016-07-25
include_once 'include/Base.php';$path = '';$url = isBase::decrypt(urlDecode($_SERVER['QUERY_STRING']));parse_str($url); //擷取通過url地址GET傳遞過來的變數if(!empty($_POST['path'])){ //擷取POST傳遞過來的變數$path = $_POST['path'];$path = isBase::decrypt(urlDecode($path));}
Time of Update: 2016-07-25
$ch = curl_init();curl_setopt($ch, CURLOPT_URL, "http://localhost/2.php");curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:8.8.8.8', 'CLIENT-IP:8.8.8.8'));//IPcurl_setopt($ch, CURLOPT_REFERER, "http://bbs.it-home.org/ ");
Time of Update: 2016-07-25
//在excel.php檔案中 $objActSheet = $objPHPExcel->getActiveSheet(); // 設定 欄目名稱 $objActSheet->setCellValue("b1", "卡號"); // 設定列的寬度 $objActSheet->getColumnDimension('b')->setWidth(20);//改變此處設定的長度數值 複製代碼2、字元被excel理解成數字了,一般就是把那個欄位設定成文本
Time of Update: 2016-07-25
function array_multi2single($array){ static $result_array=array(); foreach($array as $value) { if(is_array($value)) { array_multi2single($value); } else $result_array[]=$value; }
Time of Update: 2016-07-25
/** desc:資料庫類調用執行個體 假設你的資料類是 db_class.php link:bbs.it-home.org date:2013/2/24*/require_once("db_class.php");//1.建立類,並串連資料庫$db = new mssql("dns=aaa;uid=sa;pwd=sa;dbname=test");//2.串連資料庫$conn =
Time of Update: 2016-07-25
class Person{//下面是人的成員屬性var $name; //人的名子var $***; //人的性別var $age; //人的年齡//下面是人的成員方法function say() //這個人可以說話的方法{echo "這個人在說話";}function run() //這個人可以走路的方法{echo "這個人在走路";}}?> 複製代碼3.5.如何執行個體化對象上面說過php
Time of Update: 2016-07-25
本文執行個體講述了php中fgetcsv()函數用法。分享給大家供大家參考。具體方法如下:fgetcsv是一個簡單的產生excel文檔的函數,從 PHP 4.3.5 起,fgetcsv() 的操作是二進位安全的,執行個體代碼如下:<?php $file = fopen("contacts.csv","r"); print_r(fgetcsv($file)); fclose($file); ?>以上就是php 的 fgetcsv() 函數
Time of Update: 2016-07-25
/** 功能:郵件發送 url: http://bbs.it-home.org*/header("content-type:text/html;charset=utf-8"); $smtp = array( "url" => "郵箱SMTP伺服器位址", "port" => "郵箱SMTP伺服器連接埠", // 一般為25 "username" => "使用者名稱", "password" => "密碼", "from" => "發件地址", "to" => "收件地址", "subject"
Time of Update: 2016-07-25
/** * author: goosman * blog: http://blog.csdn.net/lgg201 * mail: lgg860911@yahoo.com.cn */ $str = '01234567890120123456789'; function substr_remain_tag($s, $o, $l) { $is_match = preg_match_all( ;
Time of Update: 2016-07-25
//存入 $arr = array(1,2,3);$arr_str = serialize($arr); setcookie("a",$arr_str); //取出 $arr_str = $_COOKIE['a']; $arr = unserialize($arr_str);複製代碼方法二:設定多索引值cookie,注意必須給索引值 $arr = array(1,2,3); setcookie("a[0]", $arr[0]); setcookie("a[1]", $arr[
Time of Update: 2016-07-25
從網上下載的源碼,在調試時大多出現 Undefined variable的錯誤。一般情況下,php是不需要定義變數的,但如果伺服器什麼都報錯的,就會出現錯誤,所以伺服器上都是應該屏蔽這種錯誤的。從網上下載的源碼,在調試時大多出現 Undefined variable的錯誤。一般情況下,php是不需要定義變數的,但如果伺服器什麼都報錯的,就會出現錯誤,所以伺服器上都是應該屏蔽這種錯誤的。Notice: Undefined variable: email in
Time of Update: 2016-07-25
Alpaca 可以輕鬆支援 iphone android 等終端。 只需要在定義 風格時,對 head 部多加註意。 在設定頁面寬度時最好不要超過 400px Hello world 複製代碼
Time of Update: 2016-07-25
if(is_uploaded_file($_FILES['myFile']['tmp_name'])){$upfile = $_FILES['upload'];$name = $upfile['name'];$type = $upfile['type'];$size = $upfile['size'];$tmp_name = $upfile['tmp_name'];$error = $upfile['error'];switch($type){case 'image/pjpeg' : $ok=1