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

Submitting the same value many times when the value needs to be unique
'Order by' specified order in Woocommerce shortcode
woocommerce hooks warning “function not found”
How to acces value from route in symfony2
Get Value Of Table Field
redirecting a long URL to https
How to embed this php code in html?
Uncaught Error: Call to undefined function curl_init()
Multi level login by address
SELECT * FROM table WHERE `id` in … and where sum() less
Laravel: Undefined method fake on Laravel storage facades for file upload testing
Very Complex SQL Data Result Merge via PHP (Multi Dimentional Arrays)
codeigniter Insert_batch not working
How do I fix this invalid JSON that wasn't escaped? (in PHP)
PHP: how to adding date with number of month from database? [duplicate]
Illegal string offset 'class' in ( php 7.1.1 ) [duplicate]

Categories

HOME
elasticsearch
office365
jms
redmine
selenium-builder
code-formatting
website
visual-studio-2010
informatica
cryptography
dji-sdk
capistrano
mithril.js
cdi
graphql-js
polymer-2.x
port
reportviewer
stack-overflow
alljoyn
grocery-crud
spring-jpa
async-await
vmware-workstation
pygobject
rpmbuild
boomi
deepfreeze
gitkraken
bsd
animated-gif
boolean-logic
bitbake
infopath2010
ms-media-foundation
polyml
bean-validation
xerces-c
nppexec
cups
testlink
jslint
ms-dos
gitolite
python-jira
opal-framework
1wire
yoast
vesta
directwrite
nusoap
head.js
entropy
gtk#
winmerge
mongodb-aggregation
test-data
1010
kendo-treeview
sidewaffle
ndk-build
data-management
raw-sockets
openseadragon
oci
wolfram-language
node.js-connect
android-syncadapter
apache-pig-grunt
gridbaglayout
management-studio-express
android-mapview
android-studio-import
gluon-desktop
apple
ngcordova
green-threads
lifetime
password-recovery
rebar
global-scope
inputbox
jquery-mobile-flipswitch
ecos
aho-corasick
siena
csslint
fileshare
gpu-programming
pre
nosql-aggregation
compiler-flags
saga
unrealscript
lru
dynamic-rdlc-generation
notin
django-filebrowser
email-verification
thejit
liveconnect
n-queens
yuidoc
gwt-celltable
jquery-1.4
directshow.net
nsconnection
gaelyk
mygeneration
dm
3270
comment-conventions

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