dAivEd Posted November 7, 2009 Report Share Posted November 7, 2009 Zinu, ka var vienu izņemt, bet ja tekstā ir daudz atstarpes? Quote Link to comment Share on other sites More sharing options...
Val Posted November 7, 2009 Report Share Posted November 7, 2009 http://php.net/manual/en/function.str-replace.php der? Quote Link to comment Share on other sites More sharing options...
dAivEd Posted November 7, 2009 Author Report Share Posted November 7, 2009 Ka jau mineju ar šo man sanāk tikai vienu atstarpi noņemt ;( Quote Link to comment Share on other sites More sharing options...
waplet Posted November 7, 2009 Report Share Posted November 7, 2009 http://www.php.net/manual/en/function.str-replace.php#94387 Quote Link to comment Share on other sites More sharing options...
Val Posted November 7, 2009 Report Share Posted November 7, 2009 nu ta neko darīt... echo str_replace(' ', '', 'asas sd ff f f f f f fff'); Quote Link to comment Share on other sites More sharing options...
marcis Posted November 7, 2009 Report Share Posted November 7, 2009 Es tomēr šādu problēmu risinātu ar pcre $text = ' jsdnf sadfnjksanf janas'; $text = preg_replace('/\s+/', ' ', $text); Quote Link to comment Share on other sites More sharing options...
Kavacky Posted November 8, 2009 Report Share Posted November 8, 2009 Ja vajag vienkārši aizvākt visas atstarpes, tad kāpēc ņemt regexu, ja parasts str_replace darbojas ātrāk? Quote Link to comment Share on other sites More sharing options...
marcis Posted November 8, 2009 Report Share Posted November 8, 2009 Ok, varbūt nesapratu jautājumu pareizi, bet man šķita, ka jāaizvāc liekās atstarpes. Visas n atstarpes pēc kārtas pārtaisīt par vienu. Quote Link to comment Share on other sites More sharing options...
dAivEd Posted November 9, 2009 Author Report Share Posted November 9, 2009 Es tomēr šādu problēmu risinātu ar pcre $text = ' jsdnf sadfnjksanf janas'; $text = preg_replace('/\s+/', ' ', $text); Paldies, ar šito man viss sanāca ta ka gribēju, bet ar preg replace ' ' (atstarpe) nenema visus arā ar explode arī. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.