Posts

Find out Maximum and Minimum number from an array. Create an Unique Array and count no of each repeat elements in an array

Image
 Find out Maximum and Minimum number from an array. Create an Unique Array and count no of each repeat elements in an array. STEP 1: First we need to declare an array of our own size with duplicate values as the array size is not mentioned to create an unique array and to count the number of repeat elements in an array. $arr=[22,4,10,13,13,13,27,92,12,20,20];   STEP 2: Then to find the maximum and minimum numbers from an array we need to declare two variables as per our choice where we need to assign the array with max() function and min() function in that two variables like here I have assign the max() function of $arr in $max variable and also  I have assign the min() function of $arr in $min variable where $ symbol is the super global variable and then I have print the output of maximum and minimum number using print_r(). NOTE: Super global variable is the pre-defined variable which is accessible from any function, class or file. $max=max($arr); $min=min($arr); print_r...

Write a program to take 10 numbers in an array and count the number of positive, negative numbers and zeros.

Image
Write a program to take 10 numbers in an array and count the number of positive, negative numbers and zeros. STEP 1: First I have taken 10 numbers in an array and you can provide any 10 nos. on your choice in an array. $arr=["-5","-4","-3","-2","-1","0","1","2","3","4"];     STEP 2: Then I have declared 3 variables. One variable is to count for positive number, another  is to count  for negative number and the last variable is  is to count  for zero number, where I have stored 0 in each variable. $posnos=0;$neganos=0;$zeronos=0;   STEP 3: Then I have stored the array values in another variable where I will count the number of values stored in the array and that's why I have used count() function. $length=count($arr); STEP 4: Then I have taken one variable $i=0 where I am checking the for loop condition that whether $i<$length and if this for loop condition  $i<$length is true t...

Take a string( ex: My address is: 3A Rashmani Road, kolkata, 711111), find out Vowel and Consonant has present. Find out the first and last alphabet. Check your variable is in form of array or not.

Image
  Take a string( ex: My address is: 3A Rashmani Road, kolkata, 711111), find out Vowel and Consonant has present. Find out the first and last alphabet.   Check your variable is in form of array or not. STEP 1: First we need to declare one string as " My address is: 3A Rashmani Road, kolkata, 711111", then we need to declare two variable, one variable for vowel as 0 and one variable for consonant as 0, but here I have taken two variables one is $vow=0 and another is $con=0. And then to remove all the spaces in between from a string I have taken str_replace() function and then again I have taken another variable where I have store the value of the string replace ( str_replace()) function. Then I have used for loop where I have declared one variable $i as 0 and then I have checked the condition if  $i<$len is true the $i variable will increase by 1 so, here I have used $i++ and then it check the if condition and if the if condition matches then it will print the vowel i.e...

My Notes On Some Basic Interview Questions Based On PHP

 My Notes On Some Basic Interview Questions Based On PHP Q1. What is meant by PHP? Ans: PHP is a PHP Hypertext Preprocessor. It is backend and untyped language. Php is also called a loosely typed language. Q2. Why PHP is called Loosely Typed Language? Explain. Ans: PHP is called Loosely Typed Language as because it is an untyped language and if we store any data in a variable their is no need for any datatype. Q3. What is meant by Hypertext? Ans: Hypertext is a text which is displayed on computer screen or laptop with reference to other text which the user can access immediately. Q4. What is meant by Preprocessor? Ans: Preprocessor is the program that processes the input data to produce the output which is the input for another program. 

PHP Array() Functions with examples (Array() Functions, Manipulate, array_pop())

Image
 Q1. What is meant by array() function? Ans: Array() function is to manipulate the array elements. Q2. What is the meaning of manipulate? Ans: Manipulate means to do the job or to execute the work efficiently without effort. Q3. What is the function of array_pop()? Explain with an example. Ans: array_pop() function is to remove the last element from an array. For Ex. : <?php $arr=array("Parnashri","Sayanti","Gargi"); $ap=array_pop($arr); print_r($ap); ?> Output: Gargi

Take 4 arrays then margin the arrays using array_combine function (PHP Array Functions).

Image
  Take 4 arrays then margin the arrays using array_combine function (PHP Array Functions). STEP 1: First of all we cannot use array_combine() function for 4 arrays because  array_combine() function  returns associative array where it will return keys and values and the keys and values size should be of same size and as array_combine() function can merge only two arrays into one array, but this array cannot merge more than two array and the size of the two arrays should be of same size. So, here as we have 4 arrays, so we need to use array_merge() function which can merge the arrays one after another and it returns index or numerical array and it can merge more than two arrays and the size of the array can also be different.  STEP 2: So, here I declared 4 arrays as shown below. $a1=array('Shounak','Arijit','Ashish'); $b1=array('Rakesh','Shubham','Partha','Sayan'); $c1=array('Naresh','Abhishek','Narayana',...