php - How to insert text into file in specific place? -
my file looks this. need append new array keys inside via file_put_contents.
<?php $translation = array( 'wyposażenie' => 'equipment', ); ?> i don't know how this. thing know have use file_put_contents($file, "'test' => 'new value',", file_append | lock_ex); put new informations @ end of file. how append new informations right after last array key. this:
<?php $translation = array( 'wyposażenie' => 'equipment', 'test' => 'new value', ); ?>
as others mentioned in comments, can done using json in better way case here how can it:
<?php $read = file_get_contents("i.txt"); $delete = strrpos($read,");",-1); $read = substr($read,0,$delete); $new_value = "'test' => 'new value',"; $read .= "\r\n\$new_value \r\n);\r\n ?>"; file_put_contents('i.txt',$read); ?>
Comments
Post a Comment