Is there any way you can overwrite a line in PHP. let me be a little more clearer using examples.
My array
array{
[DEVICE] => eth0,
[IPADDR] => 192.168.0.2,
[NETMASK] => 255.255.255.0,
[NETWORK] => 192.168.0.0,
[BROADCAST] => 255.255.255.255,
[GATEWAY] => 192.168.0.1,
[ONBOOT] => no
}
File im overwriting
DEVICE=eth0
IPADDR=192.168.200.2
NETMASK=255.255.255.0
NETWORK=192.168.200.0
BROADCAST=255.255.255.255
GATEWAY=192.168.200.1
ONBOOT=no
DNS1=195.100.10.1
Result of the File that is rewritten
DEVICE=eth0
IPADDR=192.168.0.2
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=255.255.255.255
GATEWAY=192.168.0.1
ONBOOT=no
DNS1=195.100.10.1
Note that DNS1=195.100.10.1 Stays in the file becuase it dosent have a key with the value of DNS in our array.
Thanks
You need to find an algorithm to do it :
file() function (look carefully at the options, you don't want the news line char to be included in the array).explode() each element to create a new key => value array.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With