Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]funkcja do generowania tresci
codeszan
post 1.09.2017, 20:51:04
Post #1





Grupa: Zarejestrowani
Postów: 61
Pomógł: 0
Dołączył: 2.07.2017

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


Mam taka strukturę katalogow

views
-backend
-modules
-001
--asdas.pph
--adas.php
--menu.php
-002
--menu.php
-003
--sadas.php
-024
--342.php

  1. public function getMenu()
  2. {
  3. foreach (scandir(APPPATH . 'views\\backend\\modules\\') as $dir) {
  4. if ($dir != '.' && $dir != '..') {
  5. foreach (scandir(APPPATH . 'views\\backend\\modules\\' . $dir) as $file) {
  6. if ($file != '.' && $file != '..' && $file != 'menu.php' ) {
  7. var_dump($file);
  8. }
  9. }
  10. }
  11. }
  12.  
  13. }


Chce pokazać tylko foldery nie zawierające pliku menu.php, próbuje jak poniżej ale pokazują mi sie nie te pliki co potrzeba.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 4)
Pyton_000
post 1.09.2017, 20:53:49
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

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


if(!in_array(scandir(APPPATH . 'views\\backend\\modules\\' . $dir), 'menu.php') {
echo "ok";
}
Go to the top of the page
+Quote Post
codeszan
post 1.09.2017, 21:00:48
Post #3





Grupa: Zarejestrowani
Postów: 61
Pomógł: 0
Dołączył: 2.07.2017

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


Message: in_array() expects parameter 2 to be array, string given
Go to the top of the page
+Quote Post
trueblue
post 1.09.2017, 21:03:09
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1828
Dołączył: 11.03.2014

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


Odwróć parametry.


--------------------
Go to the top of the page
+Quote Post
codeszan
post 1.09.2017, 21:28:53
Post #5





Grupa: Zarejestrowani
Postów: 61
Pomógł: 0
Dołączył: 2.07.2017

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


  1. public function getMenu()
  2. {
  3. foreach (scandir(APPPATH . 'views\\backend\\modules\\') as $dir) {
  4. if ($dir != '.' && $dir != '..') {
  5. if(!in_array('menu.php',scandir(APPPATH . 'views\\backend\\modules\\' . $dir))) {
  6. #1
  7. $this->db->select('name, number, file_start');
  8. $this->db->from('modules');
  9. $this->db->where('number', $dir);
  10. $this->db->where('visible', 1);
  11. $this->db->where('active', 1);
  12. $query = $this->db->get();
  13.  
  14. if ($query->num_rows() > 0) {
  15. return $query->result_array();
  16. } else {
  17. return false;
  18.  
  19. }
  20. }
  21. }
  22. }
  23.  
  24. }


Coś jest jeszcze nie tak, pomimo ze folderow bez pliku menu jest wiecej zwraca tylko jeden. Prawdopodobnie coś z zapytaniem. W miejscu komentarza zwraca wiecej niz jeden folder w momencie kiedy usune zapytanie.
Go to the top of the page
+Quote Post

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: 14.08.2025 - 09:10