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()"

PHP function of the day: max()

For day 3 of 21 in the “PHP Function of the day” series, I’m going to look at max().  This function takes values and returns the highest value from what you provided.  Let’s take a look. <?php echo(max(-1,0,1,2,3).'<br />’); echo(max(array(-1,0,1,2,3)).'<br />’); echo(max(array(‘a’,’b’,’c’,’d’))); ?>   See the output   You can provide a comma-delimited list or …

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

PHP function of the day: json_encode()

This is the first of 21 posts in my “PHP Function of the day” series.  These are going to be quicker posts, for the most part.  Maybe I should do it with other languages after this? 🙂 For today, let’s look at json_encode(). <?php $joe = array(“First_Name”=>”Joe”, “Last_Name”=>”Steinbring”, “Website”=>”jws.dev”); echo ‘The Array: <br />’; echo …

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