Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]jak zrobić to za pomocą funkcji
pela222
post 19.10.2020, 11:26:27
Post #1





Grupa: Zarejestrowani
Postów: 85
Pomógł: 0
Dołączył: 17.04.2013

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


Cześć,

Czy mogę prosić o pokazanie jak zmienić powtarzany przeze mnie trzykrotnie kod i zapisać w funkcji:

  1. if ($documentData['f']['comCoAL']['selected'] == 'yes') {
  2. $TBS->MergeBlock('comCoAL', $documentData['f']);
  3. } else {
  4. $TBS->MergeBlock('comCoAL', []);
  5. }
  6.  
  7. if ($documentData['f']['comCL']['selected'] == 'yes') {
  8. $TBS->MergeBlock('comCL', $documentData['f']);
  9. } else {
  10. $TBS->MergeBlock('comCL', []);
  11. }
  12. if ($documentData['f']['comCH']['selected'] == 'yes') {
  13. $TBS->MergeBlock('comCH', $documentData['f']);
  14. } else {
  15. $TBS->MergeBlock('comCH', []);
  16. }


Zrobiłem takie coś:

  1. function mergeLetter($prefix){
  2. if ($documentData['f'][$prefix]['selected'] == 'yes') {
  3. $TBS->MergeBlock($prefix, $documentData['f']);
  4. } else {
  5. $TBS->MergeBlock($prefix, []);
  6. }
  7. }
  8. mergeLetter('comCoAL');
  9. mergeLetter('comCL');
  10. mergeLetter('comCH');


Dziękuję jak zawsze za wyrozumiałość i czekam na merytoryczne wskazówki. Thx.

Ten post edytował pela222 19.10.2020, 11:34:19
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Wersja Lo-Fi Aktualny czas: 13.08.2025 - 23:52