Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> a/an
dragonsokol
post
Post #1





Grupa: Zarejestrowani
Postów: 31
Pomógł: 2
Dołączył: 23.06.2008

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


witam,
jest mozliwosc zrobienia w php czegos takiego:
a b
an a
z czego b, a to string przed ktorymi chce dac a/an
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Babcia@Stefa
post
Post #2





Grupa: Zarejestrowani
Postów: 654
Pomógł: 17
Dołączył: 19.03.2006
Skąd: z kosmosu ;)

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


Może nie działać (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

  1. <?php
  2. $str='apple banan apple banan apple citrona';
  3. $sam=array('a, e, i, o, u');
  4. $exceptions = array('user' => 'a', 'hour' => 'an', 'university' => 'a');
  5.  
  6. $arrStrings=explode(' ', $str);
  7. foreach($arrStrings as $string) {
  8.  
  9. if($exceptions[$string] != null)
  10. {
  11. $Print .= $exceptions[$string]. ' ' .$string;
  12. } else {
  13. if(in_array($string[0], $sam)) 
  14. $Print .= 'an '. $string; 
  15. else 
  16. $Print .= 'a '. $string;
  17. }
  18. }
  19. echo $Print;
  20. ?>
Go to the top of the page
+Quote Post

Posty w temacie


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: 15.10.2025 - 08:44