• 04 December

    Remove Empty Lines from File in PowerShell

    We can do several file operations using the PowerShell console. For example, creating a file, removing a file, copying and moving a file, displaying file content, etc. While working with files, you may encounter a situation where you need to delete blank lines in a file. This tutorial will show you how to remove empty […]

  • 04 December

    Fill Array with Random Numbers in JavaScript

    Using Array.from() and Math.random() method To fill array with random numbers in JavaScript: Use Math.random() to get random numbers between 0 to 1. Use array.from() with length with desired length and mapping function as () => Math.random() * 20. This mapping function will be executed for every element in the array. Let’s say we want […]

  • Extract numbers from String in PHP
    04 December

    Extract Numbers From String in PHP

    Using filter_var() method We can use the filter_var() method which filters a variable based on supplied filter flag or ID. To extract numbers from the string variable, we can pass the FILTER_SANITIZE_NUMBER_INT id. Let’s see an example using this method. [crayon-676e24f7359f8139835324/] [crayon-676e24f7359fc567232673/] This approach isn’t efficient for certain use case, and simply returns the numbers […]

  • 04 December

    Convert Pandas Dataframe Column to List

    Use Series.values.tolist() Method To convert pandas dataframe column to list: Use pd.DataFrame() to read position_salaries as a pandas data frame. Use df["Position"] to get the column position from df Use position.values to get values of the position Use position_values.tolist() to get list of position_values as position_list [crayon-676e24f735af6063742937/] The code above will print the following output […]

  • 04 December

    Create Array of Objects in PHP

    An array can contain a sequence of elements of different data types. From strings to integers to floats to objects. In this post, we will discuss the different ways to how to create an array of objects in PHP. Using [] syntax We can use the short array syntax – [] – to create an […]

  • 04 December

    Get Parameters From URL String in PHP

    Use parse_url() with parse_str() functions Use parse_url() with parse_str() to get parameters from URL String in PHP. The parse_url() function is used to return the components of a URL by parsing it and parse_str() is used to create an associate array of query parameters and their values. [crayon-676e24f735d06919666637/] [crayon-676e24f735d09309896863/] Once you have the array of […]

  • 02 December

    Pass Variable From PHP to JavaScript

    Use echo method In order to pass variable from PHP to JavaScript, you will need to use the echo statement. This will print out the variable for you. For example, if you have a variable named $name, you would use the following code: [crayon-676e24f735e97207976073/] This will output a piece of JavaScript code that looks like […]

  • 02 December

    Remove Quotes from String in PHP

    1. Remove Quotes from String in Php 1.1 Using str_replace() Method Use the str_replace() function to remove quotes from String in PHP. [crayon-676e24f735fca140683807/] [crayon-676e24f735fcd059837766/] We used str_replace() to remove double quotes and single quotes from the String. str_replace() replaces all instances of search string with replacement String. It takes three arguments: the string to search […]

  • 30 November

    Check if Array is Empty in PowerShell

    1. Introduction In PowerShell, determining if an array is empty is a fundamental task often encountered in scripting. An "empty" array here refers to one that contains no elements. For example, given an array $myArray, our goal is to ascertain whether it’s empty and act accordingly. In this article, we will see different ways to […]