Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 07-01-2007, 5:13 PM   #1
nieuws
 
nieuws's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default split -command ??

Hi,

I was trying to do the following. It's my first php "project", so it's quiet
logic that i have some problems. Perhaps the php community might help. It's
about this :

I have a txt file with the following data :

1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich 2.37; 4. John
Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;

It's a ranking of a race. Now what i want to reach is, that these names,
come into an array, eventually in an sql database. But the last thing, is
not this big problem, if I succeed in getting it into an array.

So the result might look something like this

Stijn Piot
Kim Van Rooy
....

It would be even cooler, if in front of these names was

1 | Stijn Piot | 58.12
2 | Kim Van Rooy | 1.28
3 | .... | 2.54
....
10| John Terlaeken | 1 ronde/tour/round behind

Now the last thing, I didn't tried, because it seems to complicated for my
first "project". The first however must be possible, and it can't be that
difficult. This is what I had, but it didn't worked. Can somebody help me to
reach the exact result. Thankx in advance

<? php
$textfile = "1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich
2.37; 4. John Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;"
// this is a part of the textfile

$position=split("\;", $textfile); //splitting in an array with the
semicolon, the result is an array with rows like this 1. stijn piot 58.12
$max = count($position); // counting the size of the array

$i =0;
For ($i=0; $i<$max; $i++) {
$time = split ("^[0-9]+\.[[:space]", $position[$i]); // the row 1.
stijn piot 58.12 is splitted according "number space", the result is stijn
piot 58.12
$name = split ("[0-9]+\.[0-9]+", $time[1]);
echo $name[0]; // the previous result stijn piot 58.12 is splitted
according "number.number", the final result should be stijn piot
}
// because it is a for loop, eventually i should have
//stijn piot
//kim van rooy
//.... but the farest i can get is just stijn piot and further nothing.
?>

It's not easy at all, i hope the community can do something for me. I'm sure
that this script can help quiet a lot of people.

Ciao

Stijn


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 07-01-2007, 5:13 PM   #2
KAH
 
KAH's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default split -command ??

"nieuws" <stijnthe1st@yahoo.com> wrote in
news:Lao0b.74958$F92.8325@afrodite.telenet-ops.be:

> I have a txt file with the following data :
>
> 1. Stijn Piot 58.12; 2. Kim Van Rooy 1.25; 3. Johnny Marcovich 2.37;
> 4. John Terlaeken (Bel) 1 ronde/tour; 5. Michael Bertrand 2.12;


> $position=split("\;", $textfile); //splitting in an array with the
> semicolon, the result is an array with rows like this 1. stijn piot
> 58.12
> $max = count($position); // counting the size of the array


Why are you escaping the semicolon? It does not need escaping, you
should've gotten an error about it (try setting your ERROR_REPORTING to
E_ALL while testing).


> $i =0;
> For ($i=0; $i<$max; $i++) {
> $time = split ("^[0-9]+\.[[:space]", $position[$i]); // the row
> 1.
> stijn piot 58.12 is splitted according "number space", the result is
> stijn piot 58.12
> $name = split ("[0-9]+\.[0-9]+", $time[1]);
> echo $name[0]; // the previous result stijn piot 58.12 is splitted
> according "number.number", the final result should be stijn piot
> }


I don't understand what you're doing here. Why split it several times,
with those strange patterns? Just split it once (looks to me like you're
only interested in the name, and not the time):

$name = split ("[0-9]", $position[$i]);

I recommend you use the PCRE functions, they're faster and have a very
good (IMHO) RegEx engine.

http://www.php.net/manual/en/ref.pcre.php

KAH
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
split screen Paul Console Subjects 3 06-26-2007 2:03 PM
Split screen Rob Console Subjects 3 06-26-2007 1:41 PM
Split a all-databases dump Fabian Schulz Database 0 05-31-2007 8:39 PM
RE: split with regex Armand B PHP 0 05-20-2007 6:33 PM
split with regex Patrick PHP 4 05-20-2007 6:33 PM


Featured Websites




All times are GMT +1. The time now is 7:33 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98