質問

I want to dynamically build a directory tree of my web application in PHP at build time and insert it into a PHP file. It would an n-dimensional array consisting of every file in my web root. I need to format this as a PHP file to then include in my web application.

役に立ちましたか?

解決

var_export is what you are looking for.

var_export() gets structured information about the given variable. It is similar to var_dump() with one exception: the returned representation is valid PHP code.

<?php
  file_put_contents( $myFile, var_export( $myArray, $return = true  ) );
?>
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top