Get the Server IP with Laravel

Shilpa Kalangutkar
Updated on 29-Aug-2022 09:00:15

7K+ Views

The server IP will be the IP address of the server you are connected to. When you are working with Laravel to get the server IP you can make use of $_SERVER['SERVER_ADDR']. The $_SERVER variable acts as a global variable in PHP. It holds details like header information, script location, and other miscellaneous details. Example 1 The following example retrieves the details of the $_SERVER global variable.

Check if a Laravel Collection is Empty

Shilpa Kalangutkar
Updated on 29-Aug-2022 08:52:14

18K+ Views

Before we answer the above question, let us first understand what collections are in Laravel. Collection in Laravel is an API wrapper that helps you deal with different operations to be performed on arrays. It makes use of the class Illuminate\Support\Collection to deal with arrays in Laravel. To create a collection from a given array you need to make use of the collect() helper method that returns a collection instance. Later you can use a chain of methods like converting to lowercase and sorting on the collection instance. Example  The example in this section demonstrates how to create a collection from ... Read More

Find the Largest Among Three Numbers in Go

Aman Sharma
Updated on 29-Aug-2022 08:35:25

1K+ Views

In this tutorial, we are going to see how to find the largest number among the given number in Golang. This tutorial will cover two ways to do the same thing. Explanation Suppose we have three numbers 33, 76, and 47 so we can observe that 76 > 33 76 > 47 So our Golang code should print 76 as the largest number. Defining the operation within Same Funtion Algorithm Step 1 − Declaring the variables for the number1, number2, number3, and largest of int32 data type. Step 2 − Taking the input for the number1, number2, and ... Read More

Compute Quotient and Remainder in Golang

Aman Sharma
Updated on 29-Aug-2022 08:25:03

2K+ Views

In this tutorial, we are going to understand the approach to finding the quotient and the remainder by performing the arithmetic operations on the dividend and the divisor provided as input by the user. This tutorial will cover two ways to do the same thing. Explanation To divide any number we use the “ / ” arithmetic operator and to find the remainder we use the “ % ” arithmetic operator Suppose we have a dividend 19 and a divisor 4 then the quotient and the remainder are as follows: Quotient = dividend / divisor = 19 ... Read More

Reverse an Array in JavaScript

Vivek Verma
Updated on 29-Aug-2022 08:19:42

2K+ Views

Reversing an array means that we are reversing the order of elements present in the array, but not the array itself. In simpler terms, the element at 0th index will be shifted to the last index of the array and vice versa. There are various ways to reverse an array in JavaScript in this article, we will look into these in detail − Using the reverse() method() The reverse() method in JavaScript reverses the order of the array elements. The first element in the array is swapped with the last element, the second element is swapped with the second last ... Read More

Print ASCII Values in Golang

Aman Sharma
Updated on 29-Aug-2022 08:08:07

8K+ Views

In this tutorial, we are going to learn how to find and print the ASCII value of any character or symbol in Golang. The ASCII stands for American Standard Code for Information Exchange which is a way to represent the characters, and symbols in numeric form. Printing the ASCII value using specifier Algorithm STEP 1 − Declaring the variable of string type STEP 2 − Initializing the variable. STEP 3 − Running the for loop which is printing the ASCII value for each element in the string. Example 1 In this example, we are going to print the ASCII ... Read More

Find Index of Element in Array using JavaScript

Vivek Verma
Updated on 29-Aug-2022 08:05:40

1K+ Views

Array is an object which contains multiple values of the same datatype in a sequential order. In other words, we can say that an array is a special type of object in the JavaScript. SyntaxWe can create an array in two ways in JavaScript. The syntax are given below − var arr = [val1, val2, …]; var arr = new Array(“val1”, “val2”, …) Now let us look at a simple JavaScript program to create an array and print its index values − var arr = [1, 2, 3, 4, 5]; document.write(arr[0]); Here, the program returns the content in ... Read More

Find the Area of a Circle in Golang

Aman Sharma
Updated on 29-Aug-2022 07:59:21

892 Views

In this tutorial, we are going to see the Golang program to find the Area of a Circle. The area is the total space covered by any closed figure. Formula Area of Circle - 22 / 7 * r * r r - radius of a Circle For example, the radius of a Circle is 10 cm so the Area of a Circle is − Area = 22 / 7 * 10 * 10 = 4.2857142857143 Finding the Area of a circle within the function Algorithm STEP 1 − Declaring the variables for the ... Read More

Find the Perimeter of a Rectangle in Golang

Aman Sharma
Updated on 29-Aug-2022 07:46:18

353 Views

In this tutorial, we are going to see the Golang program to find the perimeter of a rectangle. Perimeter is the total length of the boundary of any closed figure Formula Perimeter of rectangle - 2 * ( L + B ) L - Length of a rectangle B - Breadth of a rectangle For example, the length of a rectangle is 100 cm and the breadth is 50 cm so the Perimeter of a rectangle is − Perimeter = 2 * (100 + 50) cm = 2 * (150) cm = 300 ... Read More

Calculate Compound Interest Using Golang Code

Aman Sharma
Updated on 29-Aug-2022 07:37:29

567 Views

In this tutorial, we are going to see the program for calculating compound interest in Golang. It is a method of finding the accurate interest on loans in the banking and finance sector using factors like principal amount, rate per annum, and time. Due to more accuracy, the rates are higher than the simple interest. Formula compound_Interest = P * ( 1 + R / 100) ^ T P = Principal amount R = Rate per annum T = Time For example, suppose the principal amount is 1000, the rate of interest is 4 and the interval is 2 ... Read More

Advertisements