I am having trouble writing a string to a text file. The text file is created fine and it appears to be executing all the code but nothing is writing to the text file as it remains empty when opened. The final echo statement executes as well. Much appreciation for any assistance.
$String = $array1[ 0 ] . "**" . $array1[ 1 ] . "**" . $array1[ 2 ] . "**" . $array1[ 3 ];
//To Create File
$Values = 'test.txt';
// Assigns a variable to the contents of the opened file.
$EFH = fopen( $Values, 'a+' ) or die( 'Cannot open file:. $Values' );
// If the file with the handle of $EFH is opened
if ( $EFH )
$Values = file_get_contents( 'test.txt' );
// Check to see if the file is empty.
if ( strlen( $Values ) === 0 )
// Add the contents of the $String to the file
fwrite( $Values, $String . "\n" );
echo "data written successfully to the file";
} //strlen( $Values ) === 0