FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » General » PHP discussions » help
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
icon12.gif  help [message #5503] Thu, 05 September 2002 06:34 Go to next message
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

$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 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
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 Go to previous messageGo to next message
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

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.


Laughing Embarassed
Re: help [message #5520 is a reply to message #5519] Fri, 06 September 2002 01:27 Go to previous messageGo to next message
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

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



  • Attachment: isearch.inc.t
    (Size: 12.49KB, Downloaded 1331 times)
Re: help [message #5522 is a reply to message #5520] Fri, 06 September 2002 03:03 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
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 #6650 is a reply to message #5520] Sun, 20 October 2002 23:52 Go to previous messageGo to next message
valiant is currently offline  valiant   Switzerland
Messages: 80
Registered: September 2002
Location: Zurich
Karma: 0
Member
ezdb schrieb am Fre, 06 September 2002 03:27


i want to search a way to let fud support chinese search ,and not use '%' in sql

the '%' is a placeholder in sql. what has that to do with Chinese? Or what is "Chinese search" exactly?

ezdb schrieb am Fre, 06 September 2002 03:27


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



k, what has this to do with the above Chinese issue?
If I searched for "cat dog" with "and" option, i expected a result containing the words "cat" and "dog".
If I searched for "cat dog" with "or" option, i expected a result containing the words "cat" or/and "dog".

what do you want exactly? google capabilities as brackets,...?
Re: help [message #6653 is a reply to message #6650] Mon, 21 October 2002 01:23 Go to previous messageGo to next message
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

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 #6655 is a reply to message #6653] Mon, 21 October 2002 10:15 Go to previous messageGo to next message
valiant is currently offline  valiant   Switzerland
Messages: 80
Registered: September 2002
Location: Zurich
Karma: 0
Member
ezdb schrieb am Mon, 21 Oktober 2002 03:23

3.splited msg with each letter(chinese is multibyte languages),and save the letter to the field(type is varchar).


I guess I have slowly an idea what a Chinese search expression could look like. And now I also understand why you would want to split a word into letters (that wouldn't make sense in western languages, but if each letter has its meaning as in Chinese...).

I assume your modified search version works for "AND Option", right?

The only problem is now the "OR Option" as you described. It shouldn't be a big problem, I do some code diving later this day.

cya - andy
Re: help [message #6694 is a reply to message #6655] Mon, 21 October 2002 22:40 Go to previous messageGo to next message
valiant is currently offline  valiant   Switzerland
Messages: 80
Registered: September 2002
Location: Zurich
Karma: 0
Member
Sorry, gonna look at it in the next days. Got some real life news which force me react Wink
Re: help [message #6699 is a reply to message #6694] Tue, 22 October 2002 01:14 Go to previous message
ezdb is currently offline  ezdb   China
Messages: 158
Registered: May 2002
Location: china
Karma: 0
Senior Member

Razz 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:(
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: the ? operator
Next Topic: OOP php
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 10:00:35 GMT 2024

Total time taken to generate the page: 0.02276 seconds