<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>number - WP2X</title> <atom:link href="https://wp2x.com/tag/number/feed/" rel="self" type="application/rss+xml" /><link>https://wp2x.com</link> <description>We can help your Wordpress faster</description> <lastBuildDate>Sat, 16 May 2015 05:41:40 +0000</lastBuildDate> <language>en-US</language> <sy:updatePeriod> hourly </sy:updatePeriod> <sy:updateFrequency> 1 </sy:updateFrequency> <generator>https://wordpress.org/?v=5.6.16</generator> <item><title>Convert a string to a number in PHP</title><link>https://wp2x.com/convert-string-number-php/</link> <dc:creator><![CDATA[david]]></dc:creator> <pubDate>Sat, 16 May 2015 05:41:16 +0000</pubDate> <category><![CDATA[Wordpress Tips]]></category> <category><![CDATA[convert]]></category> <category><![CDATA[number]]></category> <category><![CDATA[wordpress]]></category> <category><![CDATA[wordpress plugin]]></category> <category><![CDATA[wordpress tips]]></category> <category><![CDATA[wordpress tutorial]]></category> <guid
isPermaLink="false">http://wp2x.com/?p=365</guid><description><![CDATA[<p>Convert a string to a number in PHP is quite simple, let me show you the problem and the solution for it. &#160; Here is what we need to do Input Output '2' 2 '2.34' 2.34 '0.3454545' 0.3454545 Now, let &#8216;s do the magic $num = "3.14"; $int = (int)$num; $float = (float)$num; For more ...</p><p>The post <a
rel="nofollow" href="https://wp2x.com/convert-string-number-php/">Convert a string to a number in PHP</a> appeared first on <a
rel="nofollow" href="https://wp2x.com">WP2X</a>.</p> ]]></description> <content:encoded><![CDATA[<p>Convert a string to a number in PHP is quite simple, let me show you the problem and the solution for it.<span
id="more-365"></span></p><p>&nbsp;</p><p><a
href="http://wp2x.com/wp-content/uploads/2015/05/number.png?4b2a2c&amp;4b2a2c"><img
loading="lazy" class="aligncenter size-full wp-image-366" src="http://wp2x.com/wp-content/uploads/2015/05/number.png?4b2a2c&amp;4b2a2c" alt="number" width="290" height="238" /></a></p><p>Here is what we need to do</p><pre class="lang:sh decode:true ">Input             Output
'2'               2
'2.34'            2.34
'0.3454545'       0.3454545</pre><p>Now, let &#8216;s do the magic</p><pre class="lang:default decode:true ">$num = "3.14";
$int = (int)$num;
$float = (float)$num;</pre><p>For more detail you can do like this</p><p>1. Cast the strings to numeric primitive data types:</p><pre class="lang:php decode:true ">$num = (int) "10";
$num = (double) "10.12"; // same as (float) "10.12";</pre><p>2. Perform math operations on the strings:</p><pre class="lang:php decode:true ">$num = "10" + 1;
$num = floor("10.1");</pre><p>3. Use intval() or floatval():</p><pre class="lang:php decode:true ">$num = intval("10");
$num = floatval("10.1");</pre><p>I think they are good enough for you to convert string to any number type.</p><p>The post <a
rel="nofollow" href="https://wp2x.com/convert-string-number-php/">Convert a string to a number in PHP</a> appeared first on <a
rel="nofollow" href="https://wp2x.com">WP2X</a>.</p> ]]></content:encoded> </item> </channel> </rss>