cucumber Posted August 9, 2006 Report Share Posted August 9, 2006 Uz servera php 4.0 php 5 f-ja ? $arr1 = str_split($str); $str = "Hello Friend"; kas dot Array ( [0] => H [1] => e [2] => l [3] => l [4] => o [5] => [6] => F [7] => r [8] => i [9] => e [10] => n [11] => d ) ka var uzrakstit ar php 4 f-ju split, lai panaktu tadu bashu efektu ? Link to comment Share on other sites More sharing options...
koko Posted August 9, 2006 Report Share Posted August 9, 2006 $newstr=array(); for ($i = 0; $i < strlen($str); $i++) { $newstr[]=$str{$i}; } Domaaju, ka taa vareetu iet :) Link to comment Share on other sites More sharing options...
cucumber Posted August 9, 2006 Author Report Share Posted August 9, 2006 tas variants nederas, vajaga tieshi ar regularu izteiksmi //split Link to comment Share on other sites More sharing options...
koko Posted August 9, 2006 Report Share Posted August 9, 2006 tu saspiedies? function split($str) { $newstr=array(); for ($i = 0; $i < strlen($str); $i++) { $newstr[]=$str{$i}; } return $newstr; } Tagad der? Link to comment Share on other sites More sharing options...
KAC Posted August 9, 2006 Report Share Posted August 9, 2006 (edited) ir veerts manuaalii komentus palasiit Edited September 30, 2006 by KAC Link to comment Share on other sites More sharing options...
cucumber Posted August 9, 2006 Author Report Share Posted August 9, 2006 labi savadak jatajumi uzdoshu Vai to var izdarit tikai ar regularu izteiksmi, bez cikliem un pasha veidotam kreisam split f-jam. Link to comment Share on other sites More sharing options...
v3rb0 Posted August 9, 2006 Report Share Posted August 9, 2006 (edited) $str = "Hello Friend"; preg_match_all('(.)',$str,$match); pr($match); bet kam tev ar regex, ja triviālu lietu forumā jāprasa, un dalīt pa burtam ar regex vairāk izskatās pēc zvirbuļu ķeršanas ar ceļa rulli. Edited August 9, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
Delfins Posted August 9, 2006 Report Share Posted August 9, 2006 (edited) preg_match_al('/(.)/',$text,$m); print_r($m); ja jau ļoti gribās regulārās izteiksmes... Edited August 9, 2006 by Delfins Link to comment Share on other sites More sharing options...
cucumber Posted August 9, 2006 Author Report Share Posted August 9, 2006 to -->v3rb0 :D, bet ko darit, ja savadak nevar. paldies Link to comment Share on other sites More sharing options...
J0ke Posted August 9, 2006 Report Share Posted August 9, 2006 Delfina variants atgriež kreisu array'u :> no php manuāļa: <pre> <?php $text='Viens tāds un tāda... blablabla!'; $chars = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); print_r($chars); ?> Link to comment Share on other sites More sharing options...
bubu Posted August 9, 2006 Report Share Posted August 9, 2006 :D, bet ko darit, ja savadak nevar. Kā savādāk nevar? koko tev parādīja kā var savādāk. Link to comment Share on other sites More sharing options...
Delfins Posted August 10, 2006 Report Share Posted August 10, 2006 "Hago KpyTo \m/" PS: J0ke, kāpēc kreisais array? lai cilvēks mācās... Link to comment Share on other sites More sharing options...
J0ke Posted August 10, 2006 Report Share Posted August 10, 2006 (edited) gribētos jau lai pirmām kārtām iemācītos apieties ar manuāli :/ citād dažreiz gribas izdrukāt jamo un tad kārtīgi iekraut ar to makulatūras kaudzi :D Edited August 10, 2006 by J0ke Link to comment Share on other sites More sharing options...
Recommended Posts