Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> zaiana stringów
Black-Berry
post
Post #1





Grupa: Zarejestrowani
Postów: 663
Pomógł: 6
Dołączył: 3.06.2007
Skąd: Kraków

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


Mógłby ktoś podpowiedzieć funkcję która zamienia stringi:
  • 'Db_Driver' => 'dbDriver';
  • 'Settings' => 'settings';
  • 'System_Driver_Abstract' => 'systemDriverAbstract'
  • 'small_case_value' => 'smallCaseValue';


Ten post edytował Black-Berry 2.11.2008, 21:03:04
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
sowiq
post
Post #2





Grupa: Zarejestrowani
Postów: 1 890
Pomógł: 339
Dołączył: 14.12.2006
Skąd: Warszawa

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


UPDATE 1.0 (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

  1. <?php
  2. $string = "small_case_value";
  3.  
  4. preg_match_all("/_[a-z]/", $string, $matches);
  5. foreach($matches[0] as $tmp)
  6.    $string = str_replace($tmp, strtoupper($tmp), $string);
  7.  
  8. $string = lcfirst(str_replace("_", "", $string));
  9.  
  10. echo $string;
  11. ?>


Ten post edytował sowiq 2.11.2008, 21:17:51
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: 10.10.2025 - 07:08