473,511 Members | 15,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i will kill my(sql) self ! :-)

g0c
hi all,
i really cannot find a simple exmaple for preg_match function

i whiled the files in the directory ...

$d = dir('.') or die($php_errormsg);
while (false !== ($f = $d->read())) {
if (is_file($d->path.'/'.$f)) {
if (preg_match(match????,substr($f,3))) {
// print '<option> ' . $f . '<option>';
echo "$f\n";
}
}
}
$d->close();

i want to include files begining with "tn_"
what in the heck must stand in pattern position, i tried everything ,
nothing worked
i have actually 8 files starting with tn_* of course ...

thanks
Nov 22 '05 #1
5 1096
g0c
"g0c" <RE*******@msn.com> wrote in message
news:dl***********@fegnews.vip.hr...
hi all,
i really cannot find a simple exmaple for preg_match function

i whiled the files in the directory ...

$d = dir('.') or die($php_errormsg);
while (false !== ($f = $d->read())) {
if (is_file($d->path.'/'.$f)) {
if (preg_match(match????,substr($f,3))) {
// print '<option> ' . $f . '<option>';
echo "$f\n";
}
}
}
$d->close();

i want to include files begining with "tn_"
what in the heck must stand in pattern position, i tried everything ,
nothing worked
i have actually 8 files starting with tn_* of course ...

thanks


solved : thanks ... /me stupid

/tn.+/ is the solution
Nov 22 '05 #2
g0c wrote:
i want to include files begining with "tn_"


if (substr($fname, 0, 3) == 'tn_')

--
E. Dronkert
Nov 22 '05 #3
g0c schrieb:
if (preg_match(match????,substr($f,3))) {


Use preg_match("/^tn_.*/",$f);
Or even better, don't use preg_match for this easy case because the
suggested substr-only solution is significantly faster.

OLLi
Nov 22 '05 #4
On Mon, 14 Nov 2005 16:18:02 +0100, g0c wrote:
i want to include files begining with "tn_"
what in the heck must stand in pattern position, i tried everything ,
nothing worked
i have actually 8 files starting with tn_* of course ...


$files=glob('./tn_*');
foreach ($files as $f) {
print "$f\n";
}
If you kill yourself, may I have your stereo?
--
http://www.mgogala.com

Nov 22 '05 #5
On Tue, 15 Nov 2005 01:46:25 +0100, Oliver Grätz wrote:
Use preg_match("/^tn_.*/",$f);


There is "glob" function borrowed from the older brother.

http://us2.php.net/manual/en/function.glob.php

--
http://www.mgogala.com

Nov 22 '05 #6

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

Similar topics

0
650
by: Morten Gulbrandsen | last post by:
Hi Programmers, after this legal statement ALTER TABLE EMPLOYEE TYPE =3D InnoDB; I get=20 Warnings: 0 =20 and still MySQL claims to have to use Type =3D MyISAM,
3
1726
by: Greg McClure | last post by:
Life is not good. So I've got a machine that I do some development work on, nothing major, but I'd like to keep some things intact. I'm running SQL Server 7, it's an old installation, but it...
1
1043
by: Bucko | last post by:
Hi guys, I have an app that, right now, uses a SQL Server database and very simple, universal SQL commands. I use SqlCommand, SqlDataReader and SqlDataAdapter objects. I use web.config to...
2
1076
by: Dino Buljubasic | last post by:
Hi, My application is extensivelly querying a remote server. Somebody sniffing the traffic could eventually find out all important information such as passwords (from users in datatables as...
2
1060
by: K B | last post by:
Hi, I've just started using Visual Studio 2005 but I do NOT want to use SqlExpress but my existing sql server database. I've searched and did the following: ran the aspnet_regsql.exe to update...
2
3166
by: SAL | last post by:
Hello, I am working with Framework 1.1 and Microsoft Enterprise Library 2005. I've used the Enterprise Library Configuration utility to create my app.config & dataConfiguration.config files. ...
2
1082
by: fjm | last post by:
I would like to move several sql statements outside of my php script but have yet to be successful. I moved the sql to a different location/directory then tried to call the sql with an include...
0
2881
by: kkshansid | last post by:
i cannot export my sql server database to msaccess database which i usually did successfully 3weeks ago pls help me to find the error so that i can correct it in future error is - Validating...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
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
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5072
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
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3217
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1581
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 ...
1
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.