<?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>NewSourceMedia Blog &#187; Math and Numbers</title>
	<atom:link href="http://newsourcemedia.com/blog/category/php/math-and-numbers/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Fri, 30 Dec 2011 04:30:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>PHP how to find Odd and Even numbers</title>
		<link>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/</link>
		<comments>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[check]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[compair]]></category>
		<category><![CDATA[digits]]></category>
		<category><![CDATA[even]]></category>
		<category><![CDATA[find]]></category>
		<category><![CDATA[match]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[odd]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-how-to-find-odd-and-even-numbers/</guid>
		<description><![CDATA[Here is how to find odd and even numbers in php. How to find if a number is odd or even? In PHP I learn to use the MOD (%) operator. see below for an example: $i = 10; if &#8230; <a href="http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Here is how to find odd and even numbers in php.
<span id="more-173"></span>

How to find if a number is odd or even?
In PHP I learn to use the MOD (%) operator. see below for an example: <code>$i = 10;</code>

<code>if ($i % 2) {
echo "$i is odd";
} else {
echo "$i is even";
}
</code>

You can also use the PHP "&amp;" operator that will give you better   performance
You can use the PHP code like so:

<code>$i = 10;
if ( $i&amp;1 )
{
echo "$i is odd";
}
else
{
echo "$i is even";
}</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-how-to-find-odd-and-even-numbers/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>PHP Leading Zero for Double Digit Numbers</title>
		<link>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/</link>
		<comments>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[double digit]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[leading zero]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ten.]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-leading-zero-for-double-digit-numbers/</guid>
		<description><![CDATA[How to output a number with leading zero like dates and time. Question: In php, how do I format my numbers so that all numbers have a double digit. I am displaying the number of days in a month and &#8230; <a href="http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to output a number with leading zero like dates and time.
<span id="more-171"></span>
Question:
In php, how do I format my numbers so that all numbers have a double digit. I am displaying   the number of days in a month and have to match the date formatted for day.

Answer:
Just check the number value during a loop in php to see if it's less then 10.
Php code is below:
If so then add the leading zero to your string.

<code>&lt;?
for ($num = 1; $num &lt;= 31; $num++) {
if($num&lt;10)
$day = "0$num"; // add the zero
else
$day = "$num"; // don't add the zero
echo "&lt;p&gt;$day&lt;/p&gt;";
?&gt;</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-leading-zero-for-double-digit-numbers/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP Validation Numbers Only From</title>
		<link>http://newsourcemedia.com/blog/php-validation-numbers-only-from/</link>
		<comments>http://newsourcemedia.com/blog/php-validation-numbers-only-from/#comments</comments>
		<pubDate>Tue, 30 Nov 1999 06:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Forms]]></category>
		<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[credit card]]></category>
		<category><![CDATA[digit]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[numbers]]></category>
		<category><![CDATA[phone number]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[zip code]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/1969/12/31/php-validation-numbers-only-from/</guid>
		<description><![CDATA[How to check for number values only and block or convert letter strings to integers. Question: How to validate number values to and block all letters and symbol in a form. Answer: You can check the value or convert the &#8230; <a href="http://newsourcemedia.com/blog/php-validation-numbers-only-from/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[How to check for number values only and block or convert letter strings to integers.
<span id="more-170"></span>

<strong>Question:</strong> How to validate number values to and block all letters and symbol in a form.

<strong>Answer:</strong> You can check the value or convert the value to an integer (number).

1) Check a value using is_int() to finds whether the given variable is an integer

<code>&lt;?
if(is_int($variable))
echo "Pass test";
else
echo "Please use only numbers";
?&gt; </code>

2) Note: To test if a variable is a number or a numeric string (such as form input, which is always a string), you must use is_numeric().

<code>&lt;?
if(is_numeric($variable))
echo "Pass test";
else
echo "Please use only numbers";
?&gt; </code>

3) Convert the value to an integer (number) using settype.

<code>&lt;?php
$foo = "5bar"; // string
$bar = true; // boolean</code>

settype($foo, "integer"); // $foo is now 5 (integer)
settype($bar, "string"); // $bar is now "1" (string)
?&gt;

or you can use int to do the trick.

<code>
&lt;?
$int=593; // $int is a integer
$int.=""; // $int is now a string
?&gt;
</code>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-validation-numbers-only-from/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>PHP Round Off Decimal or Convert to Decimal Point</title>
		<link>http://newsourcemedia.com/blog/php-round-off-decimal-or-convert-to-decimal-point/</link>
		<comments>http://newsourcemedia.com/blog/php-round-off-decimal-or-convert-to-decimal-point/#comments</comments>
		<pubDate>Sun, 11 Jul 2004 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Math and Numbers]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[decimal]]></category>
		<category><![CDATA[flash math]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[roudn]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2004/07/10/php-round-off-decimal-or-convert-to-decimal-point/</guid>
		<description><![CDATA[Round a number up or down or Round off a floating decimal point number using PHP's functions round(). Or convert a digit to a decimal point. Greate for shopping carts or time sheet programs. Round Off Decimal Round a number &#8230; <a href="http://newsourcemedia.com/blog/php-round-off-decimal-or-convert-to-decimal-point/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Round a number up or down or Round off a floating decimal point number using PHP's functions round(). Or convert a digit to a decimal point. Greate for shopping carts or time sheet programs.
<span id="more-194"></span>
<strong>Round Off Decimal</strong>

Round a number up or down or Round off a floating decimal point number using PHP's functions round().

Example. round();
<span style="color: #339900;"> echo round(3.4); // 3
echo round(3.5); // 4
echo round(3.6); // 4
echo round(3.6, 0); // 4
echo round(1.95583, 2); // 1.96
echo round(1241757, -3); // 1242000
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06
?&gt;</span>

<strong>Convert to Decimal Point</strong>

Example. number_format();
<span style="color: #339900;"> $number = "28";
$number = number_format($number, 2);
echo $number; // equals "28.00"
?&gt;</span>

For a good book on PHP, check out <a href="http://www.amazon.com/exec/obidos/ASIN/1861003730/newsourcemedi-20" target="_blank">Beginning PHP4</a>]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/php-round-off-decimal-or-convert-to-decimal-point/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
