Posts Tagged by PHP
PHP Tutorial: Is That Value In That Array?
| April 26, 2012 | Posted by Greg Bulmash under PHP |
I'm an array junkie. It is my go to data structure. At its simplest, an array is a variable that holds other variables. A basic array indexes the variables with a number. Here's a quick scriptlet that creates and prints out an array: $array = array("fred","barney","wilma","betty"); echo print_r($array,true); That's going to output something like this:…
PHP Tutorial: Validating Email Addresses
| April 25, 2012 | Posted by Greg Bulmash under PHP |
When you want to make sure an e-mail address is formatted correctly, a Google search will turn up a number of functions and preg/ereg regular expressions. But one of the easiest ways is to use a PHP function that has been a part of the standard PHP installation since 5.2: filter_var(). It's as simple as:…
PHP Tutorial: Case Insensitive String Comparison
| April 24, 2012 | Posted by Greg Bulmash under PHP |
One of my favorite functions in PHP is strtolower. All it does is take the contents in a string and make sure all the big letters are small letters. But it also makes life a bit easier when you're handling user-input content. If you do this comparison: if("James Van Der Beek" == "James van der…
PHP Tutorial: Spotting Even Numbers
| April 23, 2012 | Posted by Greg Bulmash under PHP |
I was in a programming interview and asked to solve some coding problems. I don't even remember the problem, but I remember a subtask: determine if a number was odd or even. My first thought was the modulus operator (%). 20 / 6 will return 3.333333. 20 % 6 will return 2. Modulus is like…
Recent Comments