oracle分割字符串split php如何用逗號把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫?
php如何用逗號把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫?分割字符串可以用explode函數(shù)$str = "1,2,3,4,5,6"$arr = explode(",",$str)foreach($a
php如何用逗號把字符串分割為數(shù)組并把數(shù)組分別寫入數(shù)據(jù)庫?
分割字符串可以用explode函數(shù)$str = "1,2,3,4,5,6"$arr = explode(",",$str)foreach($arr as $a){ #插入數(shù)據(jù)庫就可以}
MySQL截取和拆分字符串函數(shù)用法示例?
MySQL字符串函數(shù)substring:字符串截取
MySQL 字符串截取函數(shù):left(), right(), substring(), substring_index()。還有 mid(), substr()。其中,mid(), substr() 等價于 substring() 函數(shù),substring() 的功能非常強大和靈活。
1. 字符串截?。簂eft(str, length)
mysql> select left("example.com", 3)
-------------------------
| left("example.com", 3) |
-------------------------
| exa |
-------------------------
2. 字符串截取:right(str, length)
mysql> select right("example.com", 3)
--------------------------
| right("example.com", 3) |
--------------------------
| com |
--------------------------
實例:
#查詢某個字段后兩位字符
select right(last3, 2) as last2 from historydata limit 10
#從應該字段取后兩位字符更新到另外一個字段
update `historydata` set `last2`=right(last3, 2)