作者book989 (挑挑看啊!)
看板PHP
标题Re: [请益] 一一挑出资料库里的字直到特定的字
时间Fri Nov 2 09:25:18 2007
※ 引述《qazsd (nice play!)》之铭言:
: 想要取出资料库里某个栏位的值
: 且如果遇到某个字元或片段就停出取出
: 例如 "今日谚语:Where there is a will, there is a way. 2007-11-02"
: 想要只撷取 "今日谚语:"後面的内容,且若接下来有遇到 2007 就停止取出
: 如果用substr的话
: 就是 substr("今日谚语:Whe...",10)
: 但因为要取出的内容不限特定字数
: 所以如果遇到某个片段或字元就停止取出应该是可行
: 只是不知该用什麽函式较好
刚查一下 有蛮多方式的 只是效率上 不知道哪个比较好 = =
顺便附上参考网址 自己查查看
way1 没试过 不知道行不行
用strlen(string) 先计算出 整个句子有多长,然後再扣掉2007-11-02
所占的数量,就知道要用substr 取几个了
way2 也是没试过
stripos(string,find,start)
The stripos() function returns the position of the first
occurrence of a string inside another string.
就是,找到某特定字串出现的位置,再配合substr做你要做的事
参考网址
http://www.w3schools.com/php/php_ref_string.asp
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.142.192.175
1F:→ qazsd:感谢 11/04 13:47