Chirurgia spinală minim invazivă
Chirurgia spinală minim invazivă oferă pacienților oportunitatea unui tratament eficient, permițându-le o recuperare ultra rapidă și nu în ultimul rând minimizând leziunile induse chirurgical. Echipa noastră utilizează un spectru larg de tehnici minim invazive, din care enumerăm câteva: endoscopia cu variantele ei (transnazală, transtoracică, transmusculară, etc), microscopul operator, abordurile trans tubulare și nu în ultimul rând infiltrațiile la toate nivelurile coloanei vertebrale. www.neurohope.ro |
Scoate cuvinte dintr-un text . Ajutor ....
Last Updated: Feb 27 2009 19:48, Started by
meeesiatat
, Feb 18 2009 00:04
·
0
#19
Posted 19 February 2009 - 11:44
Saurian, on Feb 19 2009, 08:49, said: atunci trimite un link de unde să mă pot documenta despre asta the dragon book, sara golemon: extending and embedding php meeesiatat, on Feb 19 2009, 04:41, said: nu aia e problema . problema e cum sa fac sa imi afiseze fiecare cuvant din fisieru 'text' unu sub altu . ma poate ajuta careva ? ...... Iterezi stringul cu while si strtok() cum ti s-a arata mai sus, in bucla afisezi tokenul si ce intelegi tu prin "linie noua", "\r\n" sau "<br>" |
#20
Posted 23 February 2009 - 18:44
OriginalCopy, on Feb 19 2009, 11:44, said: the dragon book, sara golemon: extending and embedding php Știu că-s rău și sper să nu primesc un warn pentru asta dar: eu I know is the bad place to put you this question but I couldn't find your mail address. I am from a far country called Romania ( I bet you don't have a clue about the country ) and posting on a php forum I asked what was the difference between explode () and strtok (). Which is better and why? The moderator from the php section gaved me a short explanation that strtok is better but why and all about it is to complex for a PHP novice like me. I insisted to give me a link at least where I could read an explanation and he told me "the dragon book, sara golemon: extending and embedding php". The book is to expensive for me and I don't know if I can find it in Ro. So, I thought I could ask the author about this: why is strtok better than explode? If you can explain to a PHP novice it will be great or at least some link where I couldn't learn. Thanks in advance! :) sara golemon "Better" is, as always, a relative term. If we're talking raw CPU/Memory/etc, then yes... strtok() will sometimes use marginally less memory because it doesn't have to create an array structure to hold the elements. However, PHP's strtok() differs from C's strtok() in that it actually *does* copy the source string before tokenization, so with a moderately large string you can wind up using quite a bit MORE memory due to the copy, and a bit more CPU due to the repeated fcalls. Now, it also matters GREATLY what you wind up doing with the results of tokenization on which one is "better". Personally, I tend to use explode() {or preg_split()} because the array of elements I get back is just that much more convenient to work with and any potential marginal increase in CPU/memory is well worth the readability of the resulting code. Short version: strtok() *can* be "better" due to not having to create an array to hold the elements of the tokenization, or explode() *can* be better due to not having to copy the full string on the initial fcall. Go with what you find most readable and let PHP worry about making it work well. P.S. - This probably would have gone better on one of my blog posts, see: blog.libssh2.org |
#21
Posted 23 February 2009 - 19:03
OriginalCopy, on Feb 18 2009, 20:57, said: Si explode() de unde crezi ca-si ia stringul, sau isi salveaza stringul, nu tot in RAM? Nu. Deci ambele functii isi salveaza informatiile in RAM. Diferenta este ca strtok se serveste in mod secvential cu date pe masura ce citesti, deci face mai putin uz de tabelele cu simboluri (hash tables) din interiorul zend engine. Ok, ok ... complicat de inteles fara putine cunostinte despre php internals sau in general despre compilatoare/parsere ... deci tot scriind am decis sa renunt la explicatii Pur si simplu este asa: strtok() foloseste resursele mai econom (nu injecteaza date in runtime decat atunci cand este nevoie de ele - la cerere) "strtok() este pentru explode() ceea ce XMLReader este pentru DOM" cam asta e cea mai buna analogie. LE: o sa pun la cale un benchmark Desi nu cunosc intimitatile PHP, si nici macar limbajul pe exterior, as vrea totusi sa surprind cateva nuante, care mie mi se par firesti in cadrul oricarui limbaj. Daca ar trebui sa extrag toate cuvintele dintr-un sir extrem de lung, si sa le inmagazinez intr-un array de siruri, parca as prefera functia explode(), din motivul ca ar necesita un singur apel pe stiva (fata de o multitudine de apeluri ale functiei strtok()). Apoi, functia explode() foloseste exclusiv cod intern, rapid si optimizat, in timp ce blocul de cod scris de utilizator, si care foloseste functia strtok() ar fi mai lent, chiar si la operatia de "umplere" a vectorului de siruri (sistemul va efectua diverse verificari interne la fiecare element in parte, etc). Daca, in schimb, ai avea nevoie doar de primele cuvinte dintr-un sir foarte lung, mi se pare limpede ca strtok() ar fi mult mai rapida, deoarece n-ar necesita procesarea intregului sir initial. |
#22
Posted 27 February 2009 - 19:48
Saurian, on Feb 23 2009, 18:44, said: Știu că-s rău și sper să nu primesc un warn pentru asta dar: eu I know is the bad place to put you this question but I couldn't find your mail address. I am from a far country called Romania ( I bet you don't have a clue about the country ) and posting on a php forum I asked what was the difference between explode () and strtok (). Which is better and why? The moderator from the php section gaved me a short explanation that strtok is better but why and all about it is to complex for a PHP novice like me. I insisted to give me a link at least where I could read an explanation and he told me "the dragon book, sara golemon: extending and embedding php". The book is to expensive for me and I don't know if I can find it in Ro. So, I thought I could ask the author about this: why is strtok better than explode? If you can explain to a PHP novice it will be great or at least some link where I couldn't learn. Thanks in advance! :) sara golemon "Better" is, as always, a relative term. If we're talking raw CPU/Memory/etc, then yes... strtok() will sometimes use marginally less memory because it doesn't have to create an array structure to hold the elements. However, PHP's strtok() differs from C's strtok() in that it actually *does* copy the source string before tokenization, so with a moderately large string you can wind up using quite a bit MORE memory due to the copy, and a bit more CPU due to the repeated fcalls. Now, it also matters GREATLY what you wind up doing with the results of tokenization on which one is "better". Personally, I tend to use explode() {or preg_split()} because the array of elements I get back is just that much more convenient to work with and any potential marginal increase in CPU/memory is well worth the readability of the resulting code. Short version: strtok() *can* be "better" due to not having to create an array to hold the elements of the tokenization, or explode() *can* be better due to not having to copy the full string on the initial fcall. Go with what you find most readable and let PHP worry about making it work well. P.S. - This probably would have gone better on one of my blog posts, see: blog.libssh2.org PS: alea erau doua carti prima destul de renumita LE: oricum sper ca ti-e evident ca ti-a raspuns si din madria personala de "php internal" Quote and let PHP worry about making it work well. |
Anunturi
▶ 0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users