note 109051 added to function.gettext

From: Date: Sat, 16 Jun 2012 12:53:30 +0000
Subject: note 109051 added to function.gettext
Groups: php.notes 
Request: Send a blank email to php-notes+get-188641@lists.php.net to get a copy of this message
A bit easy version of the code from Anonymous. Giving an associative array to the function, you can see more easily what value is linked to what "variable". Code: function __($text, array $vars = array()) { $search = array(); $replace = array(); foreach ($vars as $key => $value) { $search[] = $key; $replace[] = $value; } return str_replace($search, $replace, _($text)); } How to use: __('I have #NUMPOSTS# posts in my database! And #NUMUSERS# users.', array('#NUMPOSTS#' => $numPosts, '#NUMUSERS# => $numUsers)); Thank you Anonymous :) ---- Server IP: 130.206.1.5 Probable Submitter: 87.221.89.30 ---- Manual Page -- http://www.php.net/manual/en/function.gettext.php Edit -- https://master.php.net/note/edit/109051 Del: integrated -- https://master.php.net/note/delete/109051/integrated Del: useless -- https://master.php.net/note/delete/109051/useless Del: bad code -- https://master.php.net/note/delete/109051/bad+code Del: spam -- https://master.php.net/note/delete/109051/spam Del: non-english -- https://master.php.net/note/delete/109051/non-english Del: in docs -- https://master.php.net/note/delete/109051/in+docs Del: other reasons-- https://master.php.net/note/delete/109051 Reject -- https://master.php.net/note/reject/109051 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#188641) next »