|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
|||
|
|||
|
strtok question
$word = strtok(" n", $quotes);
for ($i = 0; $i < 50; $i++) { echo "$word"; $word = strtok(" n"); } thats a script i have to only display the first 50 characters/words??? of a row in a database that has been given the name $quotes this code was given to me by a friend and unfortunately it is not working. does anyone have any suggestions on how to improve this code or does someone know of a better way of doing what i want. thanks for the help! |
|
#2
|
|||
|
|||
|
RE: strtok question
Probe, just gotta love dat name
|
|
#3
|
|||
|
|||
|
RE: strtok question
that did not work either
|
|
#4
|
|||
|
|||
|
RE: strtok question
|
|
#5
|
|||
|
|||
|
RE: strtok question
i am away from my home computer right now but i will report in once i get home
|
|
#6
|
||||||
|
||||||
|
RE: RE: strtok question
Quote:
No, it means the pattern can occur between 0 and 50 times... i.e. a simple phone number regexp might look like: php Code:
Cheers, Keith. |
|
#7
|
|||
|
|||
|
RE: strtok question
that new approach worked! but i also want to say:
if it is 50 words... then stop or if there is a double line break then stop what i mean by double line break is: line 1 with stuff written in it *press enter* empty line - line break *press enter* |
|
#8
|
|||
|
|||
|
RE: strtok question
|
|
#9
|
|||
|
|||
|
RE: strtok question
all i got with that were the words array
|
|
#10
|
|||
|
|||
|
RE: strtok question
maybe i didn't understand what you wanted.. sorry
|
|
#11
|
|||
|
|||
|
RE: strtok question
Notepad: How can you say that regular expression are longer to execute ?
When I code I sometimes ask myself for the quickest code but since I can't find any statistics on the time taken by functions, I tend to write code the simpliest way ? If you have pointers to such stats, I'll be happpy to see them B-) |
|
#12
|
|||
|
|||
|
RE: strtok question
i'm just going on what i've read in books, remember i'm self-taught here so please correct me if the following statement can be proven otherwise.. and i quote from: PHP and MySQL Web Development - by Luke Welling & Laura Thomson. Chapter 4 page 116
"In general, the regular expression functions run less efficiently than the string functions with similar functionality. If your application is simple enough to use string expressions, do so." |
|
#13
|
|||
|
|||
|
RE: strtok question
|
|
#14
|
|||
|
|||
|
RE: strtok question
all i get is the words array again???
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > strtok question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|