Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
php: replace funkcija unutar petlje

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
vedran



Joined: 08 Sep 2003
Posts: 458

PostPosted: 22.06.2005 13:53    Post subject: php: replace funkcija unutar petlje Add user to your forum ignore list Reply with quote

Trebao bih primjer funkcije u php-u koja bi uzela neku recenicu(naslov iz baze) i zamijenila sva przna mjesta unutar tog stringa sa - (crticom).

Naime koristim mod_rewrite i svi urlovi se otvaraju prema naslovu novosti, pa bi se ta funkcija trebala pobrinuti da u url-u nema praznih mjesta..

Pa ako netko može nabrzinu napisati primjer ili ima gotovi bio bih jako zahvalan.
Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ante



Joined: 09 Oct 2003
Posts: 255
Location: st

PostPosted: 22.06.2005 14:05    Post subject: Add user to your forum ignore list Reply with quote

Jel str_replace funkcija može?

Code:
str_replace(string to search for, replacement string, string to be searched trough);


Pogledaj u php manualu detalje i primjere. http://hr.php.net
Back to top
View user's profile Send private message
unique



Joined: 29 Mar 2004
Posts: 655

PostPosted: 22.06.2005 14:06    Post subject: Add user to your forum ignore list Reply with quote

s pretpostavkom da vec imas tu recenicu iz baze... Smile

Code:
$recenica="Dali Vedran zeli ovo?";
for ($k=0;$k<strlen($recenica);$k++) if($recenica[$k]==' ') $recenica[$k]='-';
echo $recenica;


ili ko funkcija :]
Code:
$recenica="Dali Vedran zeli ovo?";
function crtice($recenica){
for ($k=0;$k<strlen($recenica);$k++) if($recenica[$k]==' ') $recenica[$k]='-';
retrun $recenica
}
echo crtice($recenica);

_________________
Activate interlock! Dynotherms connected! Infracells up! Mega thrusters are go! LET'S GO VOLTRON FORCE!
Back to top
View user's profile Send private message
vedran



Joined: 08 Sep 2003
Posts: 458

PostPosted: 22.06.2005 14:10    Post subject: Add user to your forum ignore list Reply with quote

unique wrote:
s pretpostavkom da vec imas tu recenicu iz baze... Smile

Code:
$recenica="Dali Vedran zeli ovo?";
for ($k=0;$k<strlen($recenica);$k++) if($recenica[$k]==' ') $recenica[$k]='-';
echo $recenica;


ili ko funkcija :]
Code:
$recenica="Dali Vedran zeli ovo?";
function crtice($recenica){
for ($k=0;$k<strlen($recenica);$k++) if($recenica[$k]==' ') $recenica[$k]='-';
retrun $recenica
}
echo crtice($recenica);


Da-Vedran-želi-baš-to Very Happy
Puno hvala na brzom i točnom odgovoru.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 22.06.2005 14:26    Post subject: Add user to your forum ignore list Reply with quote

zasto bi bilo jednostavno kad moze bit komplicirano :)
ante ti je dobro rekao, treba ti str_replace

Code:
str_replace(' ', '-', $recenica);

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 22.06.2005 14:26    Post subject: Add user to your forum ignore list Reply with quote

pa zasto pisat svoju funkciju kad vec ima str_replace?
ovo radi istu stvar, ali je nezanemarivo krace
Code:
$naslov = str_replace(' ', '-', $naslov);


/EDIT/ chevap me preteko Rolling Eyes

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 22.06.2005 14:28    Post subject: Add user to your forum ignore list Reply with quote

che je preteko nel'chee Razz Wink

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group