123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- * Description of Str
- *
- * @author jgao
- */
- class Strings {
- //put your code here
-
- /**
- * 字符串包含判定
- * @param type $string 完整字符串
- * @param type $sub 子串
- * @return type
- */
- static function contains($str, $sub){
- return strpos($str, $sub) !== false;
- }
-
- /**
- * 字符串分割
- * @param type $str
- * @param type $char
- * @return type
- */
- static function split($str,$char=','){
- if($str == ""){
- return array();
- }
- $strArr = explode($char, $str);
- return $strArr;
- }
-
- /**
- * 字符串分割为二进制数据
- * @param type $str
- * @param type $char
- * @return type
- */
- static function splitRaw($str,$char=','){
- $rawArr = array();
- if($str != ""){
- $strArr = self::split($str, $char);
- foreach($strArr as $item){
- $rawArr[] = (real)$item;
- }
- }
- return $rawArr;
- }
- }
|