Click here to Skip to main content
15,444,353 members
Home / Discussions / Linux, Apache, MySQL, PHP
   

Linux, Apache, MySQL, PHP

 
GeneralRe: Database connection refused. Pin
Eddy Vluggen6-Dec-16 4:58
professionalEddy Vluggen6-Dec-16 4:58 
GeneralRe: Database connection refused. Pin
taiwokaffo6-Dec-16 23:06
Membertaiwokaffo6-Dec-16 23:06 
QuestionPHP topic selection for Final year Project Pin
Member 1278820324-Nov-16 2:51
MemberMember 1278820324-Nov-16 2:51 
GeneralRe: PHP topic selection for Final year Project Pin
Kornfeld Eliyahu Peter24-Nov-16 5:08
professionalKornfeld Eliyahu Peter24-Nov-16 5:08 
AnswerRe: PHP topic selection for Final year Project Pin
Richard MacCutchan24-Nov-16 6:37
mveRichard MacCutchan24-Nov-16 6:37 
GeneralRe: PHP topic selection for Final year Project Pin
Member 127882035-Dec-16 22:17
MemberMember 127882035-Dec-16 22:17 
GeneralRe: PHP topic selection for Final year Project Pin
Member 127882036-Dec-16 22:35
MemberMember 127882036-Dec-16 22:35 
QuestionSeveral arrays to one multidimensional Pin
Member 128309193-Nov-16 5:29
MemberMember 128309193-Nov-16 5:29 
Hello. I have a list of numbered folders. In each folder there is a lot of .jpg files. I get a list of all including image files from this directories with two glob functions dynamically. I store a list of directory paths and filenames into two separates arrays called $DIR[] and $files[].
PHP
<?php
        //FOLDERS
        //create array for each directory
        $pathDIR = "dirname/";
        $DIR = Array(
        );
        //store directory names into an array with foreach
        foreach (glob($pathDIR . '/[0-30]*', GLOB_ONLYDIR) as $dirname) {
            $DIR[] = $dirname;    
        }
        //display path directories
        for($a = 0; $a < count($DIR); $a++) {
            echo $DIR[$a];   
        }
        //FILES
        //create array for each directory
        $pathFILE = Array();
        //create array for files    
        $files = Array();            
        //loop start
        for($b = 1; $b <= count($DIR); $b++) {
            $pathFILE[$b] = "dirname/" . $b . "/"; 
            //store files in array with foreach
            foreach(glob($pathFILE[$b] . '*.jpg') as $filename) {
                $files[] = $filename;
            }
        }
        //display files
        for($c = 1; $c <= count($files); $c++) {
            echo $files[$c-1];
        }
        ?>


I have tried to combine two arrays in one multidimensional array with:
PHP
array_push ($DIR, $file);


to display array values I've tried with a pair of loops:

PHP
for($d = 0; $d <= count($DIR); $d++) {
    for($e = 0; $e <= count($DIR[$d]); $e++) {
        echo $DIR[$d][$e];
    }
}  


unfortunately array values are not properly show. Also, a notice indicate undefined offset .

Thanks a lot for your help.
AnswerRe: Several arrays to one multidimensional Pin
WildDonkey11-Feb-17 3:59
MemberWildDonkey11-Feb-17 3:59 
QuestionOOP in PHP Pin
Member 1278820328-Oct-16 4:22
MemberMember 1278820328-Oct-16 4:22 
AnswerRe: OOP in PHP Pin
Anurag Gandhi13-Nov-16 6:09
professionalAnurag Gandhi13-Nov-16 6:09 
GeneralRe: OOP in PHP Pin
Peter_in_278013-Nov-16 13:38
professionalPeter_in_278013-Nov-16 13:38 
GeneralRe: OOP in PHP Pin
Member 1278820324-Nov-16 2:03
MemberMember 1278820324-Nov-16 2:03 
GeneralRe: OOP in PHP Pin
Afzaal Ahmad Zeeshan24-Nov-16 2:19
mveAfzaal Ahmad Zeeshan24-Nov-16 2:19 
GeneralRe: OOP in PHP Pin
kribo5-Dec-16 3:26
professionalkribo5-Dec-16 3:26 
AnswerRe: OOP in PHP Pin
Anurag Gandhi5-Dec-16 3:48
professionalAnurag Gandhi5-Dec-16 3:48 
AnswerRe: OOP in PHP Pin
Afzaal Ahmad Zeeshan24-Nov-16 2:21
mveAfzaal Ahmad Zeeshan24-Nov-16 2:21 
GeneralRe: OOP in PHP Pin
Member 1278820324-Nov-16 3:21
MemberMember 1278820324-Nov-16 3:21 
AnswerRe: OOP in PHP Pin
kribo5-Dec-16 3:32
professionalkribo5-Dec-16 3:32 
GeneralRe: OOP in PHP Pin
Member 127882035-Dec-16 6:30
MemberMember 127882035-Dec-16 6:30 
QuestionRequest: Php 7 Tutorial/Course Recommendation From You Pin
Member 127834388-Oct-16 16:36
MemberMember 127834388-Oct-16 16:36 
QuestionRun multiple PHP versions on same server Pin
manhfh7-Oct-16 6:14
Membermanhfh7-Oct-16 6:14 
QuestionOnly Home page opening after going live Pin
Member 1275803925-Sep-16 20:28
MemberMember 1275803925-Sep-16 20:28 
SuggestionRe: Only Home page opening after going live Pin
Richard Deeming26-Sep-16 2:07
mveRichard Deeming26-Sep-16 2:07 
AnswerRe: Only Home page opening after going live Pin
Richard MacCutchan26-Sep-16 2:48
mveRichard MacCutchan26-Sep-16 2:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.