php去除數組中重複資料的二個例子

/*** 去除數組中重複資料* by bbs.it-home.org**/$input = array("a" => "green","", "red","b" => "green", "","blue", "red","c" => "witer","hello","witer");//$result = array_unique($input); //去除重複元素$result = a_array_unique($input); //只留下單一元素foreach($result as

PHP採集遠程圖片的執行個體代碼

function make_dir($path){ if(!file_exists($path)){//不存在則建立 $mk=@mkdir($path,0777); //許可權 @chmod($path,0777); } return true; }複製代碼函數read_filetext()取得圖片內容。使用fopen開啟圖片檔案,然後fread讀取圖片檔案內容。 function read_filetext($filepath){

php GD庫繪製24小時柱狀圖的執行個體代碼

/* 24小時柱狀圖 作者:taokey QQ:29611705* 編輯:bbs.it-home.org*/ function h24($str){ $hour = explode(",",$str); $hmax = max($hour); $ppix = 150/$hmax; //計算柱狀圖高度 $h0 = 190-$hour[0]*$ppix; $h1 = 190-$hour[1]*$ppix; $h2 =

PHP 數組字元集編碼轉換的函數

/** * 數組轉編碼 * @param array $array 待轉碼數組 * @param String $inCharset 原編碼 * @param String $outCharset 轉換後的編碼 * @return $array 轉換後的數組 * @site:bbs.it-home.org */private function arrayCoding ($array, $inCharset, $outCharset) { if (!is_array($array))

PHP實現時間軸函數(剛剛、5分鐘前)

function tranTime($time) { $rtime = date("m-d H:i",$time); $htime = date("H:i",$time); $time = time() - $time; if ($time $str = '剛剛'; } elseif ($time $min = floor($time/60); $str = $min.'分鐘前';

PHP壓縮html的函數代碼

//函數名: compress_html//參數: $string//傳回值: 壓縮後的$string//by bbs.it-home.orgfunction compress_html($string) { $string = str_replace("\r\n", '', $string); //清除分行符號 $string = str_replace("\n", '', $string); //清除分行符號 $string = str_replace("\t", '',

php curl偽造IP的範例程式碼

#!/bin/awk -f #運行前 BEGIN { FS = " "; count = 0; } #運行中 { iparr[count ++] = $0; } #運行後 END { printf(" printf("$iparr = array(\n"); for (i = 0; i printf("'%s' => '%s',\n", iparr[i], iparr[i]); }

php截取字串(無亂碼 utf8)

/*** 字串 截取函數* by bbs.it-home.org*/function msubstr($str, $start, $len) { $tmpstr = ""; $strlen = $start + $len; for($i = 0; $i if(ord(substr($str, $i, 1)) > 0xa0) { $tmpstr .= substr($str, $i, 2); $i++; }

php報表類庫jpgraph柱狀圖產生執行個體

/*** JpGraph類產生柱狀圖* by bbs.it-home.org*/$datay=array(); //縱座標資料 $datax=array(); //橫座標資料 foreach ($usernums as $key => $value){ $datay[] = $value; $datax[] = $userids[$key]; } require_once (‘jpgraph-3.0.7/jpgraph/jpgraph.php'); require_once

php 擷取網站地址的函數代碼

/*** 取得網站的完整地址* by bbs.it-home.org*/function getRootUrl(){ $name = ''; if ( isset($_SERVER['HTTP_HOST']) ){ $name = $_SERVER['HTTP_HOST']; }else{ $name = $_SERVER['SERVER_NAME']; } if ( strpos($name,':') === false && $_SERVER['SERVER_PORT'

php根據url自動產生縮圖(附源碼)

sudo a2enmod rewrite 複製代碼2,.htaccess檔案的內容: RewriteEngine On # '-s' (is regular file, with size) # '-l' (is symbolic link) # '-d' (is directory) # 'ornext|OR' (or next condition) # 'nocase|NC' (no case) # 'last|L' (last rule) RewriteCond

PHP多重判斷刪除檔案函數代碼

/*** func: delete_file* params: $file 檔案名稱* 多重條件判斷 刪除檔案* by bbs.it-home.org*/function delete_file($file) { if (file_exists($file)) { $delete = chmod ($file, 0777); $delete = unlink($file); if(file_exists($file))

PHP類比POST提交的範例程式碼

/*** PHP中CURL類比Post提交* by bbs.it-home.org*/$url = 'http://website/a.php';$fields = array('UserName'=>urlencode('a'),'PWD'=>urlencode('b') ,'AppReturn'=>urlencode('c') ,'AppSQL'=>urlencode('d') ,);$fields_string = http_build_query($fields);$ch =

PHP圖片縮小函數一例

/** * 縮小圖片函數 * 刪除了原始圖片保留了操作後的圖片 * @param string $fileName * @return void */private function createSmallImg($fileName){ list($width,$height,$type,$attr) = getimagesize($fileName); $imgOld=imagecreatefromjpeg($fileName);

PHP隨機顯示指定文本(if elseif的用法)

/*** 隨機顯示指定的文本* by bbs.it-home.org*/function getRand() { $a=rand(1,5); if ($a==1) { echo "今天晴天!"; }elseif ($a==2) { echo "今天大太陽"; }elseif ($a==3) { echo "今天下雨天"; }elseif ($a==4) { echo "今天多雲"; }elseif ($a==5) { echo "今天流星雨"; }}?>複製代碼

php 刪除記錄同時刪除圖片檔案的代碼

/*** 刪除記錄時,一併刪除圖片檔案* by bbs.it-home.org*/$cn = mysql_connect('127.0.0.1','root','root') or die('database connect fail'); mysql_select_db('test',$cn); mysql_query("set names 'gbk'"); /* 建立資料庫教程 CREATE DATABASE `test` ; 建立資料表 test1 CREATE TABLE `test`.

PHP讀取csv檔案內容的幾個例子

$file = fopen('windows_2011_s.csv','r'); while ($data = fgetcsv($file)) { //每次讀取CSV裡面的一行內容//print_r($data); //此為一個數組,要獲得每一個資料,訪問數組下標即可$goods_list[] = $data; }//print_r($goods_list);/* foreach ($goods_list as $arr){ if ($arr[0]!=""){ echo

PHP禁止IP訪問(不過濾搜尋引擎蜘蛛)的方法

/*** 屏蔽指定的IP地址訪問,但不屏蔽搜尋引擎的蜘蛛* by bbs.it-home.org*/function get_ip_data(){  $ip=file_get_contents("http://ip.taobao.com/service/getIpInfo.php?ip=".get_client_ip());  $ip = json_decode($ip);  if($ip->code){  return false;  }  $data = (array) $ip->data;

PHP 採集圖片函數一例

PHP 採集圖片函數一例 <p><?/*** 採集圖片函數* func: getimg* params: $url 網址 $filepath 圖片檔案的路徑* by bbs.it-home.org*/function getimg($url, $filepath) { </p><p> if ($url == '') {return false;}$ext = strrchr($url, '.');

php防止sql注入的程式碼範例

Function inject_check($sql_str) { return eregi('select|insert|and|or|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);}if (inject_check($_SERVER['QUERY_STRING'])==1 or inject_check(file_get_contents("php://input"))==1){ /

總頁數: 5203 1 .... 3089 3090 3091 3092 3093 .... 5203 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.