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

Select all rows from table in Yii
How to retrieve all table names from database?
PHP - How can i use str_replace in that situation?
get the value of a child
how to use my description(meta description) as a second title in joomla2.5
Can't retrieve data from MongoDb
Where is php.ini file of php_fpm?
laravel migration creates different schema
How to create facebook page with PHP or CURL?
How to convert INR to USD before passing to paypal in opencart
How to know the Dynamodb updateItem response status in AWS SDK for PHP
How can I test why sendmail / php isn't working?
Retrieve table data from another webpage using PHP
Extremely confusing (And infuriating) PHP/HTML problems
What is the facebook.com/sharer.php ios/android url schema for mobile websites?
zf2 oauth2 catching extra params

Categories

HOME
facebook-messenger
dry
adobe
ios-simulator
elisp
flurry
impala
angular-meteor
stack-overflow
slide
powermock
twisted
nest-api
pinterest
rest-assured
office-ui-fabric
string-formatting
scheduled-tasks
clr
wsf
cmake-gui
activeadmin
tableview
sybase-ase
environment
strophe.js
msdeploy
onchange
basex
math.js
adapter
sparkle
copy-protection
matlab-app-designer
snap-framework
knights-tour
mongoengine
bluemixtools
forms-authentication
gitolite
extbase
tidal-scheduler
resampling
classnotfoundexception
opal-framework
elasticsearch-aggregation
fluid-mac-app-engine
git-tfs
spongycastle
intellij-lombok-plugin
node-apn
android-sharing
algebra
zend-server
http4s
google-identity-toolkit
msg
system.web.optimization
fuzzer
openseadragon
mercurial-extension
teensy
webgrind
chicagoboss
mixins
gluon-desktop
360-degrees
libz
physicsjs
web-api
tree-structure
prism-4
mgwt
mod-auth-openidc
tkx
nanomsg
cout
windows-rt
object-code
squeezebox
category-theory
nachos
preorder
cidr
progress-db
non-ascii-characters
pacman
flv
ntlmv2
idispatch
spark-view-engine
coordinate
struts2-s2hibernate
wiktionary
quartz-core
affinetransform
qt-mobility
css-friendly
grails-validation
resharper-5.1
outlook-2007-addin
asdoc
tacit-programming
gtktextview
levels
chronic
rootkit

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