php


Using PHP, how can I add quotations to a non-standard INI file?


I'm having to work with a custom application that stores information in an INI formatted file.
Unfortunately, it doesn't use double-quotes around all the values, so PHP's parse_ini_file function won't work.
Is there some way to add quotations around ALL the values in the INI file so that the parse_ini_file would be able to parse it?
I figured out something that works for me!
$lines = file_get_contents('bravo.txt');
$search = array("=", "\r\n");
$replace = array("=\"", "\" ");
Try this:
$content = preg_replace('^([^=]+)=\s*(.*)$', '$1="$2"", $fileContent);
This should make sure you are not falsely including whitespaces in your values.

Related Links

Why create own request object? [closed]
array declration methods in php [closed]
File extension filter when choosing file to upload
Secure file storage in a server
MySQL: Avoid selecting columns with the same userid
Can't view local images with apache
Bug in Doctrine or am I doing something wrong?
Passing value along with MySQL retrieved value as hidden value in JavaScript to AJAX function
Dynamic forms and PHP
PHP MYSQL Register page Validation
How LOCK works for writing logs into flat file?
PHP mysql how to relationship three tables showing outputs from different tables
Paypal - CURL response is 0 in a new server (connection time out), it's ok in the old server
Using ajax how to get data from the database in PHP?
How to check the exception thrown correctly by PHPUnit?
How to encrypt the $_GET data in php?

Categories

HOME
amazon-web-services
xpath
orientdb
shinyapps
openxml
long-integer
postgresql-9.4
windows-10
command-prompt
hdfs
iverilog
typeerror
magento-2.0
informatica
semantic-web
haxe
u-boot
polymer-2.x
bellman-ford
xades4j
pm2
mpu6050
corona
supervisord
android-contacts
jqxgrid
hidden
rpmbuild
spring-shell
bluemix-mobile-services
chronicle-queue
web-push
gravity-forms-plugin
credit-card
markov-chains
pdfnet
aurelia-cli
sspi
imgur
flowchart
game-center
asihttprequest
gcal
spongycastle
webalizer
algebra
emacs25
dynamics-crm-4
finder
researchkit
visual-studio-monaco
nvda
seccomp
cdo.message
qpixmap
apache-pig-grunt
frame-grab
jeditable
vaadin4spring
teamviewer
wikimedia-commons
in-app-billing
extend
jolie
lifetime
quantify
lmax
nidaqmx
tabletools
usb-flash-drive
nosql-aggregation
code39
django-settings
libxml-js
lru
objective-c-runtime
office-app
linkbutton
playorm
android-dialog
server-name
netstream
multidrop-bus
play2-mini
aptitude
mygeneration
iphone-sdk-3.1.3
efs

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App