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

Scheduled entity in onFlush is different instance
php, explode is not working, php preg_replace is not working
How to save expire sesion when I close browser
Contact Form 7 - Sum validation
Android: Retrieve details from MySQL database when a cardview is clicked
Create Dynamically 2D Array [closed]
Fetch random data from database without refreshing page
Error while uploading file to PHP and displaying it using fpdf
How can I sanitize custom CSS, without it breaking?
Symfony transform ChoiceType in CheckboxType
Display variable contents with drupal_set_message
Failed loading xdebug.so undefined symbol zend_sort
Memory exhausted at 1.6G even with ini_set('memory_limit', '-1')
how to get most popular articles from model and order desc
If statement with multiple condition checks not working properly
PHP Returning two different times

Categories

HOME
php
qt
artificial-intelligence
weblogic12c
windows-8.1
opencv-python
operating-system
activemq
hdfs
supercollider
cocotb
jpa-criteria
cqrs
colors
trace32
corona
reselect
vertica
google-sites
pfobject
opam
backtracking
kamailio
stackexchange.redis
quantitative-finance
mod-wsgi
tf-idf
acrobat
bonita
javax.persistence
fusion
amazon-iam
autodesk-model-derivative
steam-web-api
rspec-rails
private-key
sca
android-collapsingtoolbar
cloveretl
express-session
jfxtras
love2d
code-rally
android-alarms
microkernel
stat
fiware-wirecloud
minikube
httphandler
transparency
spring.net
maven-jaxb2-plugin
patternlab.io
1010
mechanicalturk
p6spy
openseadragon
groovyfx
polymerfire
android-expansion-files
webgrind
enunciate
deeplink
openshift-cartridge
auto-generate
featuretoggle
unhandled
vdm-sl
nsmutabledata
mutators
tkx
adhoc-polymorphism
encryption-symmetric
datagridcomboboxcolumn
ildasm
image-rotation
mobile-country-code
reference-counting
hotswap
meteorite
compiler-flags
objective-c-runtime
void-pointers
axacropdf
email-verification
user-forums
spark-view-engine
struts2-json-plugin
instance-variables
clearinterval
server-name
struts2-s2hibernate
servercontrol
database-deadlocks
nsrangeexception
simile
nsconnection
ninject-interception
multiple-users
sscli
browser-based
dm
spring-modules
source-code-protection
fuzzy-comparison
rakudo
suggestbox
account-management
synthesizer

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