PHP function of the day: md5()

For day 12 of 21 in the “PHP Function of the day” series, I’m going to look at md5(). This function calculates the md5 hash of the string you supply as input. Let’s take a look. <?php $input = “Joe is here”; echo md5($input).”</br >”; $input = “Joe was here”; echo md5($input).”</br >”; $input = “Joe is …

Continue reading "PHP function of the day: md5()"

PHP function of the day: array_diff()

For day 11 of 21 in the “PHP Function of the day” series, I’m going to look at array_diff(). It gets the difference between an array and one or more other arrays. Let’s take a look. <?php $person1 = array(“fname”=>”Joe”,”lname”=>”Smith”); $person2 = array(“fname”=>”Jane”,”lname”=>”Smith”); $differences = array_diff($person1, $person2); print_r($differences); $person3 = array(“fname”=>”Stan”,”lname”=>”Smith”); $differences = array_diff($person1, $person2, $person3); print_r($differences); …

Continue reading "PHP function of the day: array_diff()"

PHP function of the day: min()

For day 9 of 21 in the “PHP Function of the day” series, I’m going to look at min(). This function takes values and returns the smallest value from what you provided. Let’s take a look. <?php echo(min(-1,0,1,2,3).'<br />’); echo(min(array(-1,0,1,2,3)).'<br />’); echo(min(array(‘a’,’b’,’c’,’d’))); ?>   See the output   As you can see, this is a lot like …

Continue reading "PHP function of the day: min()"

PHP function of the day: html_entity_decode()

For day 8 of 21 in the “PHP Function of the day” series, I’m going to look at html_entity_decode().  It takes HTML entities and converts them to HTML. Let’s take a look. <?php $html = ‘<h1>Hello!</h1><p>Joe\’s website is at: <a href=”https://jws.dev”>jws.dev</a></p>’; $encoded = htmlentities($html); echo $encoded.'<br />’; echo html_entity_decode($encoded); ?>   See the output   As you …

Continue reading "PHP function of the day: html_entity_decode()"

PHP function of the day: htmlentities()

For day 7 of 21 in the “PHP Function of the day” series, I’m going to look at htmlentities().  It takes HTML as an input and converts it to HTML entities. Let’s take a look. <?php $html = ‘<h1>Hello!</h1><p>Joe\’s website is at: <a href=”https://jws.dev”>jws.dev</a></p>’; echo ‘<br />’; echo $html; echo ‘<br />’; echo htmlentities($html); ?>   See …

Continue reading "PHP function of the day: htmlentities()"

PHP function of the day: json_decode()

For day 6 of 21 in the “PHP Function of the day” series, I’m going to look at json_decode().  You might remember json_encode() from last week.  Where json_encode() encodes data as JSON, json_decode() decodes JSON data. Let’s take a look. <?php $data = ‘{“First_Name”:”Joe”,”Last_Name”:”Steinbring”,”Website”:”jws.dev”}’; var_dump($data); echo(‘<br />’); var_dump(json_decode($data)); echo(‘<br />’); var_dump(json_decode($data, true)); ?>   See the output …

Continue reading "PHP function of the day: json_decode()"

PHP function of the day: array()

For day 5 of 21 in the “PHP Function of the day” series, I’m going to look at array().  Array() is what you use to create an array in PHP. Let’s take a look. <?php $array = array(1, 2, 3, 4); print_r($array); echo(“<br />”); $array = array(“Joe”, “Paul”, “Lisa”); print_r($array); echo(“<br />”); $array = array(“Name”=>”Joe”,”Address”=>”123 N Main …

Continue reading "PHP function of the day: array()"

PHP function of the day: gettimeofday()

For day 4 of 21 in the “PHP Function of the day” series, I’m going to look at gettimeofday().  The function gets the current time of the day. Let’s take a look. <?php print_r(gettimeofday()); ?>   See the output   Since gettimeofday() outputs an array, we are using print_r() instead of echo() but don’t focus …

Continue reading "PHP function of the day: gettimeofday()"