Click here to Skip to main content
15,894,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
define('DB_NAME', 'example1');
/** MySQL database username */
define('DB_USER', 'example2');
/** MySQL database password */
define('DB_PASSWORD', 'example3');
/** MySQL hostname */
define('DB_HOST', 'example4');
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');
/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');


This is a block of code in my wordpresse's wp-config.php file. I have wrote a c# app to download this file via ftp. But how can I manipulate the file so that I get

$db_name = "example1";
$db_user = "example2";
$db_password = "example3";.......


Thanks
Posted
Updated 19-Feb-10 15:55pm
v2

1 solution

with the Replace method on the string class, at first, you'll need some more basic string mashing to turn DB_NAME into $db_name, but it's possible. You can turn

define('DB_NAME', 'example1');

into

DB_NAME = "example1";

with the replace method. Then use Split to split on the =. Then use ToLower to turn DB_NAME into db_name. Put a $ in front and replace the = between and you are done.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900