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 ) );
?>