Created
July 18, 2012 23:18
-
-
Save BenjaminGuV/3139635 to your computer and use it in GitHub Desktop.
crear archivos multiples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dir = $_SERVER['DOCUMENT_ROOT']; | |
?> | |
<html> | |
<head> | |
<title></title> | |
</head> | |
<body> | |
<?php | |
$arrayCiudad = array(); | |
$direccion = $dir . rtrim(dirname($_SERVER['PHP_SELF'] ) ); | |
$direccion = preg_replace('/\/\//', '/', $direccion) . "/"; | |
foreach ($ciudades as $key) { | |
$temp = "Renta-De-Autos-En-" . ucwords( $key['ciudad'] ); | |
$arrayCiudad[] = preg_replace('/ /', '-', $temp ); | |
$nombre_carpeta = $direccion . $temp; | |
if(!is_dir($nombre_carpeta)){ | |
@mkdir($nombre_carpeta, 0700); | |
$archivo = $nombre_carpeta . "/" . "index.php"; | |
//Abres el archivo | |
$fp = fopen($archivo,"w"); | |
//Creas una o más variables con contenido | |
$variable = "<?php echo 'hola en " . $temp . " '; ?>"; | |
//Metes el contenido de la variable en el archivo | |
fwrite($fp, $variable); | |
//Cierras el archivo | |
fclose($fp); | |
$dic = $direccion . $nombre_carpeta . '/'; | |
$codigo = 'send.php'; | |
$destino = $nombre_carpeta . "/" . "config.php"; | |
$datos = file_get_contents( $codigo ); | |
$handle = fopen( $destino , "w"); | |
fwrite($handle , $datos); | |
fclose($handle); | |
}else{ | |
echo "Ya existe ese directorio\n"; | |
} | |
} | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment