String formatting in PHP. Nothing complex and easy to use.
function printes($expression, $args = array()) {
/*
* String formatting in PHP.
* @param (string):required $expression String witch is try to formatting.
* @param (array):required $args Array witch is formatting string form.
*
* @return (string) Fromatting string.
*/
return str_replace(array_map(function($val){return "[:$val]";}, array_keys($args)), array_values($args), $expression);
}
(string) (required) Expression string witch is try to formatting.
Eg:'Name : [:array_key1] [:array_key2]'
Eg:'Name : [:0] [:1]' , 'Name : [:fname] [:lname]'
$args(array) (optional) Array witch is formatting string form.
PHP version 4.0.1+
Before formatting, Need to make expression string. Nothing complex, only few thing do you want to know.
Eg: array('sherly','rudrigo'); this array keys are 0,1.
Then you need to made expression like 'Name : [:0] [:1]'.
Eg: array('lname'=>'rudrigo', 'fname'=>'sherly'); this array keys are fname,lname.
Then you need to made expression like 'Name : [:fname] [:lname]'.
Array variable key replace from value on expression string '[:array_key]'.
printes('Name : [:0] [:1]',array('sherly','rudrigo')); // print: Name : sherly rudrigo
printes('Name : [:fname] [:lname]',array('lname'=>'rudrigo', 'fname'=>'sherly')); // print: Name : sherly rudrigo
Who get fresh code scripts from codrate!
Will send your codrate site configuration email in your mail account.
codrate.com is a standard, fast cross browsing and highly versatile site. It is useful for many large number of Program Development Industries. So you can get support form Codrators , who are the codrate's joiners around world to help your program developments, You can answer other codrator's questions. Communicate with them. Share your knowledge with them. Do you have an interest in programming, So publish your articles about programming. It will help to maintain your professional co-profile. Actually codrate.com is not such as a regular web site. It will be gave new experience, best narrow cross-browser view, reduce processing time to receive browsing request, it's mean do not wasting your time to browsing codrate's web pages because it has been upgrade always modern coding ways. So, what do you waiting for ?. Try your own.