473,472 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

string comparison in php

hi

i am writing a small application where a user enters a phrase in the
textfield and i would like to display all the files present in the
root directory which consists of the keyword or keywords entered by
the user.

i have used a few comparison functions but i am not getting the
expected result.

$my_file = file_get_contents("filename.html");
what ever the user enters whether it is a single word or few words i
would like to compare with $my_file in a case insensitive manner.

can anyone suggest the best method and how to go about.

thanks.
Jul 14 '08 #1
3 1739
On Jul 14, 1:33 pm, Sudhakar <sudhakarar...@gmail.comwrote:
hi

i am writing a small application where a user enters a phrase in the
textfield and i would like to display all the files present in the
root directory which consists of the keyword or keywords entered by
the user.

i have used a few comparison functions but i am not getting the
expected result.

$my_file = file_get_contents("filename.html");
what ever the user enters whether it is a single word or few words i
would like to compare with $my_file in a case insensitive manner.

can anyone suggest the best method and how to go about.

thanks.
i think the Reg_Expression works for u.

VM
Jul 14 '08 #2

"Sudhakar" <su***********@gmail.comwrote in message
news:1c**********************************@26g2000h sk.googlegroups.com...
hi

i am writing a small application where a user enters a phrase in the
textfield and i would like to display all the files present in the
root directory which consists of the keyword or keywords entered by
the user.

i have used a few comparison functions but i am not getting the
expected result.

$my_file = file_get_contents("filename.html");
what ever the user enters whether it is a single word or few words i
would like to compare with $my_file in a case insensitive manner.

can anyone suggest the best method and how to go about.

thanks.
http://in2.php.net/manual/en/class.dir.php

Look for the "User Contributed Notes" at the end.

do search for "auto suggest" in search..
Jul 14 '08 #3
Sudhakar wrote:
hi

i am writing a small application where a user enters a phrase in the
textfield and i would like to display all the files present in the
root directory which consists of the keyword or keywords entered by
the user.

i have used a few comparison functions but i am not getting the
expected result.

$my_file = file_get_contents("filename.html");
what ever the user enters whether it is a single word or few words i
would like to compare with $my_file in a case insensitive manner.

can anyone suggest the best method and how to go about.

thanks.
This can get complicated quickly. If they enter one word, you can
easily search each file for that word. If they enter two words, what if
those words appear, but not together?

Either way, you will need to open each file, read it into memory and
search it. You can do it in your PHP program, but you might find it
faster to execute grep and let the system do it.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jul 14 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: yadurajj | last post by:
Hello i am newbie trying to learn C..I need to know about string comparisons in C, without using a library function,...recently I was asked this in an interview..I can write a small program but I...
5
by: MaSTeR | last post by:
Can anyone provide a practical short example of why in C# I shouldn't compare two strings with == ? If I write this in JAVA String string1 = "Widget"; if (string1 == "Widget") ...
4
by: Peter Kirk | last post by:
Hi I am looking at some code which in many places performs string comparison using == instead of Equals. Am I right in assuming that this will in fact work "as expected" when it is strings...
4
by: Jim Langston | last post by:
Is there any builtin lowercase std::string compare? Right now I'm doing this: if ( _stricmp( AmmoTypeText.c_str(), "GunBullet" ) == 0 ) AmmoType = Item_Ammo_GunBullet; Is there anything the...
26
by: Neville Lang | last post by:
Hi all, I am having a memory blank at the moment. I have been writing in C# for a number of years and now need to do something in VB.NET, so forgive me such a primitive question. In C#, I...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.