protected function search_folders( $path ) {
		$return       = array();
		$base_folders = array_filter( glob( $this->trailingslashit( $path ) . '*' ), 'is_dir' );

		if ( is_array( $base_folders ) && ! empty( $base_folders ) ) {
			foreach ( $base_folders as $folder ) {
				$_sub = $this->search_folders( $this->untrailingslashit( $folder ) );

				if ( is_array( $_sub ) && ! empty( $_sub ) ) {
					$return = array_merge( $return, $_sub );
				} elseif ( is_string( $_sub ) ) {
					$return = array_merge( $return, array( $_sub ) );
					$return = array_merge( $return, array( $this->untrailingslashit( $path ) ) );
				}
			}
		} else {
			$return = array( $this->trailingslashit( $path ) );
		}

		return $return;
	}
protected function search_folders( $path ) {
		$return       = array();
		$base_folders = array_filter( glob( $this->trailingslashit( $path ) . '*' ), 'is_dir' );

		if ( is_array( $base_folders ) && ! empty( $base_folders ) ) {
			foreach ( $base_folders as $folder ) {
				$_sub = $this->search_folders( $this->untrailingslashit( $folder ) );

				if ( is_array( $_sub ) && ! empty( $_sub ) ) {
					$return = array_merge( $return, $_sub );
				} elseif ( is_string( $_sub ) ) {
					$return = array_merge( $return, array( $_sub ) );
					$return = array_merge( $return, array( $this->untrailingslashit( $path ) ) );
				}
			}
		} else {
			$return = array( $this->trailingslashit( $path ) );
		}

		return $return;
	}
protected function search_folders ( $ path ) { $ return = array ( ) ; $ base_folders = array_filter ( glob ( $ this -> trailingslashit ( $ path ) . '*' ) , 'is_dir' ) ; if ( is_array ( $ base_folders ) && ! empty ( $ base_folders ) ) { foreach ( $ base_folders as $ folder ) { $ _sub = $ this -> search_folders ( $ this -> untrailingslashit ( $ folder ) ) ; if ( is_array ( $ _sub ) && ! empty ( $ _sub ) ) { $ return = array_merge ( $ return , $ _sub ) ; } elseif ( is_string ( $ _sub ) ) { $ return = array_merge ( $ return , array ( $ _sub ) ) ; $ return = array_merge ( $ return , array ( $ this -> untrailingslashit ( $ path ) ) ) ; } } } else { $ return = array ( $ this -> trailingslashit ( $ path ) ) ; } return $ return ; }
Search folders & subfolders inside a given folder and returns it.

@param $path

@return array|string
Search folders & subfolders inside a given folder and returns it .