Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Kasowanie wybranych znakow w ciagu
-nocas-
post
Post #1





Goście







Witam, mam taki problem, mam ciag, ktory zawiera jakis tam tekst, jak zrobic by skrypt usunal z niego wszystkie z wybranych przeze mnie znakow. Sorki, jesli temat sie powtarza.
Go to the top of the page
+Quote Post
dag
post
Post #2





Grupa: Zarejestrowani
Postów: 180
Pomógł: 0
Dołączył: 24.12.2003

Ostrzeżenie: (0%)
-----


str_replace" title="Zobacz w manualu PHP" target="_manual
preg_replace" title="Zobacz w manualu PHP" target="_manual

  1. <?php
  2.  
  3. // Provides: Hll Wrld f php
  4. $vowels = array(&#092;"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\");
  5. $onlyconsonants = str_replace($vowels, &#092;"\", \"Hello World of php\");
  6.  
  7. ?>
Go to the top of the page
+Quote Post
stefan_precz
post
Post #3





Grupa: Zarejestrowani
Postów: 134
Pomógł: 0
Dołączył: 2.01.2005

Ostrzeżenie: (0%)
-----


a jakby wyglądało w tym przypadku podmienianie znaków, zrobiłem tak ale coś nie działa

  1. <?php
  2.  
  3. $szukaj = array(&#092;"a\", \"e\", \"i\", \"o\", \"u\", \"ż\");
  4. $podmien = array(&#092;"A\", \"3\", \"|\", \"0\", \"u\", \"sh\");
  5. $text = preg_replace($szukaj, $podmien, &#092;"i tutaj jakis tekst już\");
  6.  
  7. echo&#092;"$text\";
  8. ?>
Go to the top of the page
+Quote Post
dag
post
Post #4





Grupa: Zarejestrowani
Postów: 180
Pomógł: 0
Dołączył: 24.12.2003

Ostrzeżenie: (0%)
-----


Zajrzałeś chociaż do str_replace" title="Zobacz w manualu PHP" target="_manual


  1. <?php
  2. // Provides: You should eat pizza, beer, and ice cream every day
  3. $phrase = &#092;"You should eat fruits, vegetables, and fiber every day.\";
  4. $healthy = array(&#092;"fruits\", \"vegetables\", \"fiber\");
  5. $yummy = array(&#092;"pizza\", \"beer\", \"ice cream\");
  6.  
  7. $newphrase = str_replace($healthy, $yummy, $phrase);
  8.  
  9. ?>


Ten post edytował dag 6.07.2005, 20:43:33
Go to the top of the page
+Quote Post
-Gość_gostek-
post
Post #5





Goście







A jeśli chcę str_replace zamienić znaczek '\' na coś innego (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
  1. <?php
  2.  
  3. str_replace(&#092;"\", \"W\", $table[$i]);
  4.  
  5. ?>

To nie działa (IMG:http://forum.php.pl/style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
nospor
post
Post #6





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




  1. <?php
  2.  
  3. str_replace(&#092;"\", \"W\", $table[$i]);
  4.  
  5. ?>
znaki specjalne trzeba poprzedzać \
Go to the top of the page
+Quote Post
-Guest-
post
Post #7





Goście







Cytat(nospor @ 2005-07-13 12:13:06)
znaki specjalne trzeba poprzedzać \

No dobrze... Nadal nie działa (IMG:http://forum.php.pl/style_emoticons/default/worriedsmiley.gif)


Mamy sobie taki kodzik:
  1. <?php
  2.  
  3. str_replace(&#092;"\", \"\", $table[$i]);
  4. echo &#092;"$table[$i]\";
  5. ?>
Go to the top of the page
+Quote Post
crash
post
Post #8





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


str_replace zwraca zmieniony ciąg, a nie zmiania ciągu podanego w argumencie:
  1. <?php
  2. $table[ $i ] = str_replace( &#092;"\", \"\", $table[ $i ] );
  3. echo $table[ $i ];
  4. ?>
Go to the top of the page
+Quote Post
-Guest-
post
Post #9





Goście







Cytat(crashu @ 2005-07-13 12:23:53)
str_replace zwraca zmieniony ciąg, a nie zmiania ciągu podanego w argumencie:

Jesteście boscy! (IMG:http://forum.php.pl/style_emoticons/default/Rkingsmiley.png) Dzięki bardzo. Działa jak miało. (IMG:http://forum.php.pl/style_emoticons/default/laugh.gif)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 06:53