Home » 2021 » November

PHP: Process Each Item In An Array with array_map() [Examples]

PHP array_map

This article will show you how to process a PHP array using array_map() to run a function on each item in the array. Why use array_map()? Arrays store a sequence of values in a single variable. If you’re storing those values, you probably want to do something with them at some point. Say, for example, you had an array of numbers, and you wanted to calculate the square of each number to be stored in a new array. You could create an empty array, loop through the original array calculating … Read more

Categories PHP

Home » 2021 » November

Rounding Numbers Down with the PHP floor() Function, with Examples

PHP floor()

This short tutorial will cover how to use the PHP floor() function to round numbers DOWN – and provide some code examples. The PHP floor() function rounds a number down (and only down!) to the nearest integer. To round a number up to the nearest integer, use the ceil() function instead. To round a number normally, or for more options when rounding a number, use the round() function. PHP floor() Function Syntax The syntax for the PHP floor() function is as follows: floor($NUMBER) Note that: $NUMBER is the float or integer number you wish to perform the floor() operation on floor() will return a float type number regardless of … Read more

Categories PHP

Home » 2021 » November

TwisterOS For Raspberry Pi Does It All [Screenshots/Review]

twister os for raspberry pi

Here’s a screenshot-heavy review of Twister OS – a weird, kitchen-sink included Linux OS for Raspberry Pi with tools for emulation, gaming, and overclocking.  It even comes with Windows and macOS themes! Rather than make you read about what it does, I’ve included screenshots walking through the process of downloading, installing, and running Twister OS.  I’ve included some commentary, but the screenshots should let you decide for yourself whether you want to give this odd OS a go. First up, downloading and installing Twister OS … Read more

Home » 2021 » November

Rounding Numbers Up with the PHP ceil() Function, with Examples

PHP ceil()

This short tutorial will cover how to use the PHP ceil() function to round numbers UP – and provide some code examples. The PHP ceil() function rounds a number up (and only up!) to the nearest integer. To round a number down to the nearest integer, use the floor() function instead. To round a number normally, or for more options when rounding a number, use the round() function. PHP ceil() Function Syntax The syntax for the PHP ceil() function is as follows: ceil($NUMBER) Note that: $NUMBER is the float or integer number you wish to perform the ceil() operation on ceil() will return a float type number regardless of … Read more

Categories PHP

Home » 2021 » November

How to Use the PHP ‘while’ Loop, With Examples

PHP while

This tutorial will teach you how to use the while statement to build loops in the PHP programming language and show some examples. The while loop is the most straightforward kind of loop in PHP. The code inside the loop will execute for as long as the while condition is true. Change the condition, and the loop will exit. while loops are a fundamental part of PHP (and loops are an essential part of computer programming in general) – so it’s good to know how they work and what they can be … Read more

Categories PHP

Home » 2021 » November

How to Use the PHP ‘do while’ Loop, With Examples

PHP do while

This tutorial will teach you how to use the do while statement to build loops in the PHP programming language, and show some examples. The do while loop is one of the simplest types of loop in PHP. The code inside the loop will execute for as long as the do while condition is true. Change the condition, and the loop will exit. do while loops are a fundamental part of PHP (and loops are an essential part of computer programming in general) – so it’s good to get to know how they … Read more

Categories PHP

Home » 2021 » November

How to Use the Python slice() Function, With Examples

Python slice()

The Python slice() function can be used to get a portion of a list, tuple, string, or other sequence. This article will show you how to use it. Python slice() Function Syntax Here’s the syntax for the Python slice() function: slice(START, STOP, STEP) Note that: slice() does not return the specified portion of an object It returns a slice object which is used to retrieve the specified portion from a sequence – it does not contain the sequence itself. This is probably best demonstrated in the below examples START is the starting position (index) of the sequence you … Read more

Home » 2021 » November

What is a Python Dictionary? Explanation and Code Examples

Python dictionary

Here’s everything you need to know about the Dictionary data type in Python, what it can store, and how to use it. Python has several built-in data types for storing data (more than other languages like JavaScript) – from basic types like integers, floating-point numbers, and strings to more complex types like lists, tuples, and dictionaries. What is a Type? A variable’s type defines what kind of value it can store and what can be done with it. What is a Dictionary? A dictionary is a variable type … Read more

Home » 2021 » November

How to Add/Append Items to a Dictionary in Python [Examples]

Add Item to Python Dictionary

This short tutorial will show you how to add single or multiple items (as key:value pairs) to a dictionary in the Python programming language. What is a Dictionary in Python? We’ve covered what dictionaries are in our article here. There are a couple of ways to add items to a dictionary, so we’ve put together this article separately to make sure we’ve got everything covered! Checking Whether a Key Exists in a Dictionary As outlined in the article linked above, dictionaries store data as a series of key:value pairs. Before … Read more

Home » 2021 » November

Quick and Dirty CCTV with Raspberry Pi, MotionEyeOS + Webcam

home cctv motioneyeos

In this article, I’ll walk through the process of setting up MotionEyeOS on a Raspberry Pi, using a cheap USB webcam to create a DIY CCTV system. MotionEyeOS is a pre-configured Linux distribution that turns your Raspberry Pi into a home CCTV system.  You can set up multiple cameras and set them to detect motion or record on a timer, and send the resulting photos and videos to you via email or save them to online storage. What You’ll Need A Raspberry Pi A USB … Read more