help [message #5503] |
Thu, 05 September 2002 06:34 |
|
$str="abcd........";
//i want to get a function like this but work faster :
function spstr($str){
$len=strlen($str);
for($i=0;$i<$len;$i++){
$arr[]=substr($str,$i,1);
}
return $arr;
}
$arr=spstr($str);
=========
$arr[0]="a";
$arr[1]="b";
.
.
[Updated on: Thu, 05 September 2002 06:51] Report message to a moderator
|
|
|
Re: help [message #5512 is a reply to message #5503] |
Thu, 05 September 2002 14:17 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
You do not need to do what you are doing.
In php a string can already be accessed like an array if you need a particular character.
for example:
$str = '123456';
echo $str[2];
would echo '3' and so on.
FUDforum Core Developer
|
|
|
Re: help [message #5519 is a reply to message #5512] |
Fri, 06 September 2002 00:43 |
|
prottoss wrote on Thu, 05 September 2002 22:17 | You do not need to do what you are doing.
In php a string can already be accessed like an array if you need a particular character.
for example:
$str = '123456';
echo $str[2];
would echo '3' and so on.
|
|
|
|
Re: help [message #5520 is a reply to message #5519] |
Fri, 06 September 2002 01:27 |
|
my function is out
function sp_str($str){
$str = trim(preg_replace('/\"|\'|\;|\\\\|\s+/', '', $str));
$len=strlen($str);
for($i=0;$i<$len;$i++){
if (ord($str[$i]) > 128){
$arr[]=$str[$i].$str[$i+1];
$i++;
}else{
$arr[]=$str[$i];
}
}
return $arr;
}
i want to search a way to let fud support chinese search ,and not use '%' in sql
it isn't work as my thought now
eg:
keyword is "ab cd"
if user selected 'and'
then
word='a' and word='b' and word='c' and word='d'
if selected or
then
word='a' or word='b' or word='c' or word='d'(it is bad!)
===============
(word='a' and word='b') or (word='c' and word='d')
if like this ,it would be work well
|
|
|
Re: help [message #5522 is a reply to message #5520] |
Fri, 06 September 2002 03:03 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
I honestly do not know, maybe someone on the forum got any ideas...
FUDforum Core Developer
|
|
|
|
Re: help [message #6653 is a reply to message #6650] |
Mon, 21 October 2002 01:23 |
|
yes I agree with you !
I only want to find a way(search) to fix data structure like fud
fud is splited a message with " " and insert the word to fud.search!
but when you write with chinese ," " isn't be used!
so I must change the type of "word" from varchar(255) to TEXT,and save all the msg to the field
because it is no space ,the msg may be like this "abc,def.g....."
so I have three way to do this
1.save all msg to the field (type is text)
2.splited msg with "," or "." or ":"....... and save the sentence to the field (type is varchar)
sql:
select * from fud.search where word like '%bc%' or word like '%de%'
select * from fud.search where word like '%bc%' and word like '%de%'
3.splited msg with each letter(chinese is multibyte languages),and save the letter to the field(type is varchar).
sql:
used the fud's method
|
|
|
|
|
Re: help [message #6699 is a reply to message #6694] |
Tue, 22 October 2002 01:14 |
|
thanks for your help:)
I wish we will learn more about php through it.Now I use the 1 or 2 method to support chinese search:) the 3 one,I has found a way not long ago. but the script is not good:(
|
|
|