<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[FrontAccounting forum — php 7.4 function money_format() is deprecated]]></title>
	<link rel="self" href="https://frontaccounting.com/punbb/extern.php?action=feed&amp;tid=9223&amp;type=atom" />
	<updated>2021-03-08T08:12:51Z</updated>
	<generator>PunBB</generator>
	<id>https://frontaccounting.com/punbb/viewtopic.php?id=9223</id>
		<entry>
			<title type="html"><![CDATA[Re: php 7.4 function money_format() is deprecated]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39240#p39240" />
			<content type="html"><![CDATA[<p>Hello again,</p><p>I see that we already have a money_format that has been used for OS Win in /includes/current_user.inc on line 369:<br /></p><div class="codebox"><pre><code>// function money_format doesn&#039;t exist in OS Win.
if (!function_exists(&#039;money_format&#039;))
{
    function money_format($format, $number) 
    {
        return price_format($number);
    } 
}    </code></pre></div><p>All windows users have been using this routine for years without problems. Maybe we should include the function here suggested by @PaulSipley instead. I see that this function is listed in PHP.NET as an alternative to money_format. There is also another slightly better version we can use.</p><p>What do you think?</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2021-03-08T08:12:51Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39240#p39240</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: php 7.4 function money_format() is deprecated]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39239#p39239" />
			<content type="html"><![CDATA[<p>Attachment is the code in file format.</p>]]></content>
			<author>
				<name><![CDATA[apmuthu]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=364</uri>
			</author>
			<updated>2021-03-08T07:46:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39239#p39239</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: php 7.4 function money_format() is deprecated]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39230#p39230" />
			<content type="html"><![CDATA[<p>@joe, as a workaround this is what I did for another website that needed the&nbsp; money_format() function.</p><p>A proper refactoring to a supported library/function would be preferred, but this works as an interim solution.</p><p>Hope this helps</p><p>money_format.php</p><p>&lt;?php</p><p>/**<br />* Implementation of money_format function for platforms that do not<br />* implictly support it<br />*<br />*<br />* @link&nbsp; &nbsp; &nbsp; &nbsp;paulshipley.com.au<br />* @since&nbsp; &nbsp; &nbsp; 1.0.0<br />* @see&nbsp; &nbsp; &nbsp; &nbsp; https://www.php.net/manual/en/function.money-format.php<br />*<br />* @package&nbsp; &nbsp; Winesbydesign<br />* @subpackage Winesbydesign/includes<br />*/</p><p>if (!function_exists(&#039;money_format&#039;)) {<br />&nbsp; &nbsp; /*<br />&nbsp; &nbsp; That it is an implementation of the function money_format for the<br />&nbsp; &nbsp; platforms that do not it bear.</p><p>&nbsp; &nbsp; The function accepts to same string of format accepts for the<br />&nbsp; &nbsp; original function of the PHP.</p><p>&nbsp; &nbsp; (Sorry. my writing in English is very bad)</p><p>&nbsp; &nbsp; The function is tested using PHP 5.1.4 in Windows XP<br />&nbsp; &nbsp; and Apache WebServer.<br />&nbsp; &nbsp; */<br />&nbsp; &nbsp; function money_format($format, $number)<br />&nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; $regex&nbsp; = &#039;/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?&#039;.<br />&nbsp; &nbsp; &nbsp; &nbsp; &#039;(?:#([0-9]+))?(?:\.([0-9]+))?([in%])/&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; if (setlocale(LC_MONETARY, 0) == &#039;C&#039;) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setlocale(LC_MONETARY, &#039;&#039;);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; $locale = localeconv();<br />&nbsp; &nbsp; &nbsp; &nbsp; preg_match_all($regex, $format, $matches, PREG_SET_ORDER);<br />&nbsp; &nbsp; &nbsp; &nbsp; foreach ($matches as $fmatch) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = floatval($number);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $flags = array(<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;fillchar&#039;&nbsp; =&gt; preg_match(&#039;/\=(.)/&#039;, $fmatch[1], $match) ?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $match[1] : &#039; &#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;nogroup&#039;&nbsp; &nbsp;=&gt; preg_match(&#039;/\^/&#039;, $fmatch[1]) &gt; 0,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;usesignal&#039; =&gt; preg_match(&#039;/\+|\(/&#039;, $fmatch[1], $match) ?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $match[0] : &#039;+&#039;,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;nosimbol&#039;&nbsp; =&gt; preg_match(&#039;/\!/&#039;, $fmatch[1]) &gt; 0,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;isleft&#039;&nbsp; &nbsp; =&gt; preg_match(&#039;/\-/&#039;, $fmatch[1]) &gt; 0<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $width&nbsp; &nbsp; &nbsp; = trim($fmatch[2]) ? (int)$fmatch[2] : 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $left&nbsp; &nbsp; &nbsp; &nbsp;= trim($fmatch[3]) ? (int)$fmatch[3] : 0;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $right&nbsp; &nbsp; &nbsp; = trim($fmatch[4]) ? (int)$fmatch[4] : $locale[&#039;int_frac_digits&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $conversion = $fmatch[5];</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $positive = true;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($value &lt; 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $positive = false;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value&nbsp; *= -1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $letter = $positive ? &#039;p&#039; : &#039;n&#039;;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $prefix = $suffix = $cprefix = $csuffix = $signal = &#039;&#039;;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $signal = $positive ? $locale[&#039;positive_sign&#039;] : $locale[&#039;negative_sign&#039;];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (true) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $locale[&quot;{$letter}_sign_posn&quot;] == 1 &amp;&amp; $flags[&#039;usesignal&#039;] == &#039;+&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $prefix = $signal;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $locale[&quot;{$letter}_sign_posn&quot;] == 2 &amp;&amp; $flags[&#039;usesignal&#039;] == &#039;+&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $suffix = $signal;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $locale[&quot;{$letter}_sign_posn&quot;] == 3 &amp;&amp; $flags[&#039;usesignal&#039;] == &#039;+&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $cprefix = $signal;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $locale[&quot;{$letter}_sign_posn&quot;] == 4 &amp;&amp; $flags[&#039;usesignal&#039;] == &#039;+&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $csuffix = $signal;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $flags[&#039;usesignal&#039;] == &#039;(&#039;:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case $locale[&quot;{$letter}_sign_posn&quot;] == 0:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $prefix = &#039;(&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $suffix = &#039;)&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!$flags[&#039;nosimbol&#039;]) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $currency = $cprefix .<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ($conversion == &#039;i&#039; ? $locale[&#039;int_curr_symbol&#039;] : $locale[&#039;currency_symbol&#039;]) .<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $csuffix;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $currency = &#039;&#039;;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $space&nbsp; = $locale[&quot;{$letter}_sep_by_space&quot;] ? &#039; &#039; : &#039;&#039;;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = number_format($value, $right, $locale[&#039;mon_decimal_point&#039;],<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $flags[&#039;nogroup&#039;] ? &#039;&#039; : $locale[&#039;mon_thousands_sep&#039;]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = @explode($locale[&#039;mon_decimal_point&#039;], $value);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $n = strlen($prefix) + strlen($currency) + strlen($value[0]);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($left &gt; 0 &amp;&amp; $left &gt; $n) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value[0] = str_repeat($flags[&#039;fillchar&#039;], $left - $n) . $value[0];<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = implode($locale[&#039;mon_decimal_point&#039;], $value);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($locale[&quot;{$letter}_cs_precedes&quot;]) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = $prefix . $currency . $space . $value . $suffix;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = $prefix . $value . $space . $currency . $suffix;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if ($width &gt; 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $value = str_pad($value, $width, $flags[&#039;fillchar&#039;], $flags[&#039;isleft&#039;] ?<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; STR_PAD_RIGHT : STR_PAD_LEFT);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $format = str_replace($fmatch[0], $value, $format);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; return $format;<br />&nbsp; &nbsp; }<br />}</p>]]></content>
			<author>
				<name><![CDATA[PaulShipley]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=20029</uri>
			</author>
			<updated>2021-03-07T22:59:20Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39230#p39230</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: php 7.4 function money_format() is deprecated]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39228#p39228" />
			<content type="html"><![CDATA[<p>We could use the NumberFormatter instead, but it is handling it differently. I wonder how important this is?<br />We could simply skip the currency formatter, I guess. What do you guys think? Right now it is not used seriously. We could use the number_format2, like we do normally.</p><p>/Joe</p>]]></content>
			<author>
				<name><![CDATA[joe]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=3</uri>
			</author>
			<updated>2021-03-07T16:43:51Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39228#p39228</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[php 7.4 function money_format() is deprecated]]></title>
			<link rel="alternate" href="https://frontaccounting.com/punbb/viewtopic.php?pid=39226#p39226" />
			<content type="html"><![CDATA[<p>line 776 of pdf_report.inc uses function money_format() that is deprecated in php7.4</p>]]></content>
			<author>
				<name><![CDATA[notrinos]]></name>
				<uri>https://frontaccounting.com/punbb/profile.php?id=36772</uri>
			</author>
			<updated>2021-03-07T08:08:31Z</updated>
			<id>https://frontaccounting.com/punbb/viewtopic.php?pid=39226#p39226</id>
		</entry>
</feed>
