主要的函式如下:
1.將字串轉為大寫或小寫: $ $
2.生成字串: __randomstring函式
3.取字串中的子串: __substring函式
4.從檔案中按行取字串: _stringfromfile函式 (注:然後取子串,進行處理,取行中特點的值)
5.分割字串 用指定的分割符分割: __split或者$
函式的組合使用
檔案test.txt中每行資料的格式為:13400000001,123456
要求:從檔案中取出手機號,作為引數
方法:1.先利用__stringfromfile函式從檔案中取出一行資料
即:$
2.然後利用__substring函式取出行資料中的前11個字元,即手機號,如下:
$,0,11,)}
3.__lowercase函式 __uppercase函式 轉變大小寫 $
$4.__randomstring函式 生成特定長度,由指定的字元組成的字串 $
5.__substring函式 取字串中的子串,指定起始下標 $
6._stringfromfile函式 從檔案裡面取資料,按行取
7._stringfromfile函式是從乙個檔案中讀取乙個字串,用來實現引數化,
一次讀取一行 $
8.__filetostring函式 將檔案轉換為字串 $
$,,)} 分割字串
9.另一種js分割方法
$
常用字串函式
memset 原型 extern void memset void buffer,int c,int count 用法 include 功能 把buffer所指記憶體區域的前count個位元組設定成字元c。說明 返回指向buffer的指標。舉例 memset.c include include ma...
常用字串函式
獲取檔案目錄 dirname c test web home.php 將字串填充到指定長度 str pad str,10,str pad both 重複指定字串 str repeat 4 按照指定長度將字串分割到陣列中 str split str,4 字串反轉 strrev str 大小寫轉換 st...
常用字串函式
strlen string 得到字串長度 strpos string,search offset 在指定字串中查詢目標字串第一次出現的位置 stripos string,search offset 忽略大小寫的去查詢 strrpos string,search offset 在指定字串中查詢目標字串...