|
Ako PHP funkcia vracia viaceré premenné ako arrayPHP funkcia môže vracať viac premenných použitím premmennej typu array. Hlavná idea spočíva v tom, že funkcia v PHP môže vracať premenné do hlavného scriptu ako návratovú hodnotu funkcie (return statement).
Príklad:
function split_string($my_string) { $my_array = split(" ", $my_string); return $my_array; } // Teraz môžeme predať string na vstupe do funkcie split_string() $collect_array = split_string("We are the best");
V príklade posielame string na vstupe do php funkcie split_string(). Tento string následne funkcia rozdelí pomocou príkazu split a vytvorí premennú typu array. Tento array vrátime pomocou returnu do hlavného php scriptu.
Komentáre
2022-02-24 06:58 | Komentovať
![]()
2022-06-27 09:02 | Komentovať
![]()
2022-07-14 18:39 | Komentovať
![]()
2022-07-17 06:29 | Komentovať
![]()
2022-07-20 21:48 | Komentovať
![]()
2022-07-22 18:25 | Komentovať
![]()
2022-07-24 17:10 | Komentovať
![]()
2022-07-30 05:29 | Komentovať
![]()
2022-07-31 04:36 | Komentovať
![]()
2022-07-31 16:44 | Komentovať
![]()
2022-08-23 23:43 | Komentovať
![]()
2022-09-02 14:11 | Komentovať
![]()
2022-09-15 23:56 | Komentovať
![]()
2022-09-18 16:43 | Komentovať
![]()
2022-09-29 14:10 | Komentovať
![]()
2022-11-13 12:38 | Komentovať
![]()
2022-11-18 10:15 | Komentovať
![]()
2023-03-24 09:08 | Komentovať
![]()
2023-04-05 22:54 | Komentovať
![]()
2023-07-20 22:31 | Komentovať
![]()
2023-07-23 23:33 | Komentovať
![]()
2023-09-17 11:06 | Komentovať
![]()
2024-02-19 14:09 | Komentovať
![]()
2024-05-18 06:35 | Komentovať
![]()
2024-05-19 10:35 | Komentovať
![]()
2024-05-26 06:49 | Komentovať
![]()
2024-06-30 01:09 | Komentovať
![]()
2024-06-30 15:09 | Komentovať
![]()
2024-08-02 11:59 | Komentovať
![]()
2024-08-28 18:40 | Komentovať
![]()
2024-08-30 04:57 | Komentovať
![]()
2024-09-02 05:08 | Komentovať
![]()
2024-10-16 04:41 | Komentovať
![]()
2024-10-17 05:49 | Komentovať
![]()
2024-10-20 10:34 | Komentovať
![]()
2024-11-17 12:22 | Komentovať
![]()
2024-11-17 20:32 | Komentovať
![]()
2025-01-10 17:24 | Komentovať
![]()
2025-01-13 21:19 | Komentovať
![]()
2025-01-22 21:37 | Komentovať
![]()
2025-02-12 05:33 | Komentovať
![]()
2025-02-28 22:22 | Komentovať
![]()
2025-05-11 20:22 | Komentovať
![]() Pridať komentár
|
![]() |
Zoznam článkov o PHP
Ako funkcia vracia premenne v array Šikovné utilitky |
Tvorba web stránok a Webdizajn © 2009 - 2025 Supremus.sk |