Creating folders with php loop

Hello Experts,
I have the following code:

<?php

for($counter = 1; $counter <= 50; $counter++)

	
			print "AJ00" . "$counter" . "<br>";
		
	
?>

Open in new window


This code will print AJ001. AJ002, AJ003 until AJ0050,

How can I create a folder for each reference, a folder named : AJ001, another folder named AJ002 until I reach the last folder AJ0050...

Thank you
thebest8Asked:
Who is Participating?
 
Julian HansenConnect With a Mentor Commented:
This should do what you want (mkdir())
<?php
define('FOLDER_PATH','YOUR PATH HERE');
for($counter = 1; $counter <= 50; $counter++) {
  $path = FOLDER_PATH . "AJ00{$counter}";
  echo "Creating {$path} ...";
  if (mkdir($path)) {
    echo "Success<br>";
  }
  else {
    echo "Failed<br>";
  }
}

Open in new window

2
 
NorieVBA ExpertCommented:
Where do you want to create the folder(s)?
0
 
thebest8Author Commented:
Awsome, thanks alot
0
 
Julian HansenCommented:
You are welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.