PHP Get Annuaires et Seuls les répertoires

  • joebert
  • Sledgehammer
  • Genius
  • No Avatar
  • Inscription: Fév 10, 2004
  • Messages: 13458
  • Loc: Florida
  • Status: Offline

Message Janvier 9th, 2010, 12:01 pm

Façon toute simple pour obtenir une liste d'annuaires et de répertoires seulement à partir du répertoire en cours tout en excluant le point et point-point.

PHP Code: [ Select ]
<?php
 
$dirs = glob('./*', GLOB_ONLYDIR);
 
print_r($dirs);
 
?>
  1. <?php
  2.  
  3. $dirs = glob('./*', GLOB_ONLYDIR);
  4.  
  5. print_r($dirs);
  6.  
  7. ?>


Pour une liste des répertoires qui ressemble à ce qui suit

BASH Code: [ Select ]
joebert@home:~/Desktop/test$ ls -la
total 20
drwxrwxrwx  4 joebert joebert 4096 2010-01-09 13:55 .
drwxr-xr-x 18 joebert joebert 4096 2010-01-09 13:47 ..
drwxr-xr-x  2 joebert joebert 4096 2010-01-09 13:55 dir-one
drwxr-xr-x  2 joebert joebert 4096 2010-01-09 13:55 dir-two
-rw-r--r--  1 joebert joebert    0 2010-01-09 13:55 one.txt
-rw-r--r--  1 joebert joebert  130 2009-12-21 01:03 _.php
  1. joebert@home:~/Desktop/test$ ls -la
  2. total 20
  3. drwxrwxrwx  4 joebert joebert 4096 2010-01-09 13:55 .
  4. drwxr-xr-x 18 joebert joebert 4096 2010-01-09 13:47 ..
  5. drwxr-xr-x  2 joebert joebert 4096 2010-01-09 13:55 dir-one
  6. drwxr-xr-x  2 joebert joebert 4096 2010-01-09 13:55 dir-two
  7. -rw-r--r--  1 joebert joebert    0 2010-01-09 13:55 one.txt
  8. -rw-r--r--  1 joebert joebert  130 2009-12-21 01:03 _.php


Cette méthode va retourner le texte suivant

Code: [ Select ]
Array
(
  [0] => ./dir-one
  [1] => ./dir-two
)
  1. Array
  2. (
  3.   [0] => ./dir-one
  4.   [1] => ./dir-two
  5. )
Strong with this one, the sudo is.
  • Anonymous
  • Bot
  • No Avatar
  • Inscription: 25 Feb 2008
  • Messages: ?
  • Loc: Ozzuland
  • Status: Online

Message Janvier 9th, 2010, 12:01 pm

  • jpitassi
  • Born
  • Born
  • No Avatar
  • Inscription: Fév 03, 2010
  • Messages: 1
  • Status: Offline

Message Février 3rd, 2010, 9:35 am

Merci pour ceci. Je savais qu'il y avait un moyen d'obtenir l'aide d'une seule ligne. très apprécié.

Afficher de l'information

  • Total des messages de ce sujet: 2 messages
  • Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 170 invités
  • Vous ne pouvez pas poster de nouveaux sujets
  • Vous ne pouvez pas répondre aux sujets
  • Vous ne pouvez pas éditer vos messages
  • Vous ne pouvez pas supprimer vos messages
  • Vous ne pouvez pas joindre des fichiers
 
 

© 2011 Unmelted, LLC. Ozzu® est une marque déposée de Unmelted, LLC