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

Button wont open mailto:address based off of dropdown from mySQL database
fatal error in php and mysql
how to get video id or url after uploading with youtube data v3 php
How do `intval()` and `(int)` handle whitespace?
pagination not working with where condition
Custom post category query
php json read file
Dynamically setting class attribute to a symfony2 choice list generated from an entity in FormBuilder
Transfer RFID tag no. to mysql
How To Set Up Multiple WordPress Sites on a Single Ubuntu Instance with an Nginx VPS
Class 'GlobalSetting' not found in ( sfPropelRoute.class.php )
Palpal Mass Payment Responce
How to display selected textarea value in html
SSO Login without Page refresh
ZF2 - MySQL Regex for Whole word searches
Convert date stored as VARCHAR in MYSQL to MYSQL Compatible Date [duplicate]

Categories

HOME
orientdb
user-interface
svn
functional-programming
long-integer
tabs
web2py
fogbugz
turbojpeg
ag-grid
parsley.js
async-await
pygobject
exe
jqxgrid
hidden
gmp
cpu-usage
pfobject
raml
libgit2
workday
data-collection
strophe.js
gravity-forms-plugin
math.js
bitbake
audit
xenapp
windowsiot
snap-framework
series
quickcheck
jade4j
strapi
telephonymanager
netapp
contactless-smartcard
httphandler
git-tfs
ipp-protocol
entropy
solr-query-syntax
sonatype
lvalue
d3v4
libharu
msg
seccomp
callouts
jtag
groovyfx
exists
currency-exchange-rates
jsr363
management-studio-express
ioctl
servicestack-bsd
gdl
lovefield
ora-04091
blank-line
featuretoggle
unhandled
modern.ie
sequence-sql
google-gdk
webproject
tkx
directorysearcher
sunos
famo.us
dnsjava
ildasm
oxygene
assetic
jmenubar
objective-c-runtime
rikulo
ofstream
thejit
n-queens
nosetests
grails-validation
ios-4.2
icicles
zend-test
bindable-linq

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile