I fetches content from my .php file and want to push in an array the fetched result is something like:
//english error
$lang['error_incorrect_login'] = "The username or password doesn't match. Please try again";
$lang['error_user_exist'] = "The Username already exist in database. Please try using a different Username";
$lang['error_email_exist'] = "Email address already exist in database";
this is the actual content of my .php file
and I need result array like:
array(
['error_incorrect_login'] = "The username or password doesn't match. Please try again",
['error_user_exist'] = "The Username already exist in database. Please try using a different Username",
['error_email_exist'] = "Email address already exist in database"
);
I actually want to parse
$lang['error_incorrect_login'] = The username or password doesn't match. Please try again";
type of statements & push in to an array like.
array(
['error_incorrect_login'] = "The username or password doesn't match. Please try again",
['error_user_exist'] = "The Username already exist in database. Please try using a different Username",
['error_email_exist'] = "Email address already exist in database"
);
Thanks friends I used explode
over '=' like this:
$lang = '$lang';
$content = array();
while (!feof($fp)) {
$line = trim(fgets($fp));
if ( ($line != "<?php if (!defined('BASEPATH')) exit('No direct script access allowed');") && ($line != "") ) {
$explode = explode("=", $line);
$content['log'][] = str_replace( "']", "", str_replace( $lang . "['", "", trim( $explode[0] ) ) );
if (!isset($explode[1]))
$msg = "";
else
$msg = str_replace( ";", "", str_replace( "'", "", trim( $explode[1] ) ) );
$content['msg'][] = $msg;
}
}