Posts

Showing posts from June, 2025

Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String

Image
  Programmings Based On Array And String Functions To Merge The 2 Arrays, Then After Merge Convert Into String And Then Find Out The 1st And Last Word From The Reverse String Q1. Take 2 arrays then margin the arrays. After margin convert into string then reverse the string and find out 1st and last word from the reverse string. Ans: Coding => <?php $arr1 =[ "Dhoni" , "Rohit" , "Kohli" , "Rahul" ]; $arr2 =[ "Bumrah" , "Shami" , "Siraj" , "Chahal" ]; $arrmer = array_merge ( $arr1 , $arr2 ); print_r ( $arrmer ); echo "<br>" ; $str = implode ( " " , $arrmer ); print_r ( $str ); echo "<br>" ; $strrev = strrev ( $str ); print_r ( $strrev ); echo "<br>" ; $arr = explode ( " " , $strrev ); print_r ( $arr ); echo "<br>" ; $firstword = array_shift ( $arr ); $lastword = array_pop ( $arr ); print_r ( $firstword ); echo "...

Programmings Based On Array And String Functions To Find How Many Numbers Of Positive, Negative And Zero Numbers Present In The Array $arr=array(-1,-2,-3,-4,0,0,1,2,3,4)

Image
Programmings Based On Array And String Functions To Find How Many Numbers Of Positive, Negative And Zero Numbers Present In The Array $arr=array(-1,-2,-3,-4,0,0,1,2,3,4) Q1. Find how many numbers of Positive, Negative, 0 numbers present in this array. $arr=array(-1,-2,-3,-4,0,0,1,2,3,4) Ans: Coding => <?php $arr = array (- 1 ,- 2 ,- 3 ,- 4 , 0 , 0 , 1 , 2 , 3 , 4 ); $pn = 0 ; $nn = 0 ; $zn = 0 ; $len = count ( $arr ); for ( $i = 0 ; $i < $len ; $i ++) {     if ( $arr [ $i ]> 0 ) {         $pn ++;     }     else if ( $arr [ $i ]< 0 ) {         $nn ++;     }     else {         $zn ++;     } } echo "The positive number present in the array is: " . $pn . "<br>" ; echo "The negative number present in the array is: " . $nn . "<br>" ; echo "The zero number present in the array is: " . $zn ; ? > Output Of The Coding => Explanation Of Th...

Programmings Based On Array And String Functions Including Printing The Array Using Echo, Finding Out The 1st And Last Word In A Sentence, Finding Out The 1st Alphabet From A String And Also To Check Whether My Variable Is In Form Of Array Or Not

Image
Programmings Based On Array And String Functions Including Printing The Array Using Echo Where We Cannot Concatenate The Index Number, Finding Out The 1st And Last Word In A Sentence, Finding Out The 1st Alphabet From A String And Also To Check Whether My Variable Is In Form Of Array Or Not Q1. Print the array using echo where ou cannot concatinate the index number. Ans: Coding Example No. - 01 => <?php $arr =[ "500" , "1000" , "1500" , "2000" ]; $len = count ( $arr ); for ( $i = 0 ; $i < $len ; $i ++) {     echo " $arr [ $i ]" ; } ? > <?php $arr =[ "500" , "1000" , "1500" , "2000" ]; $len = count ( $arr ); for ( $i = 0 ; $i < $len ; $i ++) {     echo " $arr [ $i ]" . "<br>" ; } ? > Output Of The Coding Example No. - 01 => Coding Example No. - 02 => <?php $arrayName = array ( '100' , '200' , '300' , '400...

Full Concepts On array_flip() Function With 3 Coding Examples Prepared By Me Of Array Functions In PHP

Image
Full Concepts On array_flip() Function With 3 Coding Examples Prepared By Me Of Array Functions In PHP Q1. What is meant by array_flip()? Ans: array_flip() function is the swapping between keys and values. Coding Example 1 of array_flip() function => <?php $arrayName = array ( 'Name' => 'Ratan Tata' , 'Founder' => 'TCS' ); $arrflip = array_flip ( $arrayName ); print_r ( $arrflip ); ? > Example Of Coding Example 1 of array_flip() function => Coding Example 2 of array_flip() function => <?php $arrayName = array ( 'Name' => 'Parnashri' , 'Age' => '22' , 'Company' => 'RPS Solution' ); $arrflip = array_flip ( $arrayName ); print_r ( $arrflip ); ? > Example Of Coding Example 2 of array_flip() function => Coding Example 3 of array_flip() function => <?php $arrayName = array('Name Of The Series' => 'Money Heist', 'Release Date' => ...

MINI PROJECT ON USER INPUT TRACKER (STORE FORM SUBMISSIONS (LIKE FEEDBACK OR SURVEY DATA) IN AN ASSOCIATIVE ARRAY AND DISPLAY ONLY THE FIELDS (KEYS) THAT WERE FILLED OUT BY THE USER) AND TO GET ALL SUBMITTED FIELD NAMES FROM THE USER INPUT BY USING ARRAY_KEYS() FUNCTION

Image
MINI PROJECT ON USER INPUT TRACKER  BY USING ARRAY_KEYS() FUNCTION (STORE FORM SUBMISSIONS (LIKE FEEDBACK OR SURVEY DATA) IN AN ASSOCIATIVE ARRAY AND DISPLAY ONLY THE FIELDS (KEYS) THAT WERE FILLED OUT BY THE USER) AND TO GET ALL SUBMITTED FIELD NAMES FROM THE USER INPUT BY USING ARRAY_KEYS() FUNCTION STEP 1: In my first step first I have created an HTML form where I have design a simple html form which html file I have named it as userinputtracker.html file with multiple input fields like Name, Email, Age And Feedback Message with button submit along with method post as because the post method is the most secure method so that it can send the data securely and with action as thankyou page i.e. thatnkyou.php. I have provided name attributes in each input fields so that it can be accessed in PHP. <! DOCTYPE html > < html > < head >     < meta charset = "utf-8" >     < meta name = "viewport" content = "width=device-width, initial-sc...

Full Concepts On array_keys() Function With 3 Coding Examples Prepared By Me Of Array Functions In PHP

Image
Full Concepts On array_keys() Function With 3 Coding Examples Prepared By Me Of Array Functions In PHP Q1. What is meant by array_keys()? Ans: array_keys() returns an array containing the keys. Coding Example : 01 => <?php $arrayName = array ( 'name' => 'Ayan' , 'age' => '28' , 'gender' => 'male' ); $arrkeys = array_keys ( $arrayName ); print_r ( $arrkeys ); ? > Output Of The Coding Example : 01 => Coding Example : 02 => <?php $arrayName = array ( 'Company Name' => 'Capgemini' , 'Established Year' => '1967' ); $arrkeys = array_keys ( $arrayName ); print_r ( $arrkeys ); ? > Output Of The Coding Example : 02 => Coding Example : 03 => <?php $arrayName = array ( 'Name of the cricketer' => 'M.S.Dhoni' , 'Team' => 'India' ); $arrkeys = array_keys ( $arrayName ); print_r ( $arrkeys ); ? > Output Of The Coding Example : ...

Full Concepts On array_reverse() Function Along With A Coding Example Prepared By Me Of Array Functions In PHP

Image
Full Concepts On array_reverse() Function Along With A Coding Example Prepared By Me Of Array Functions In PHP Q1. Why the array elements are not reversed while using "array_reverse($arr);"? Ans: The array elements are not reversed while using array_reverse($arr) because after manipulation it's not able to store anywhere, but the array_reverse() function is working. Q2. Why in other functions manipulation is working and output is generated while in "array_reverse($arr)" manipulation is not working and output is not reversed? Ans: In other functions manipulation is working and output is generated while in "array_reverse($arr)" manipulation is not working and output is not reversed because in other functions we are either adding or deleting the array elements where in adding the array elements it is fixed while in deleting the array elements we are terminating the array elements , so there is nothing to store after manipulation, but in array_reverse() fu...

Full Concepts On array_shift() And array_unshift() Function With 3 Coding Examples Each Prepared By Me Of Array Functions In PHP

Image
Full Concepts On array_shift() And array_unshift() Function With 3 Coding Examples Each Prepared By Me Of Array Functions In PHP Q1. What is meant by array_shift()? Ans: array_shift() removes the first element of an array. Coding Example : 01 => <?php $arr =[ "Dog" , "Cat" , "Tiger" ]; $arrshift = array_shift ( $arr ); print_r ( $arr ); ? > Output Of Coding Example : 01 => Coding Example : 02 => <?php $arr =[ "3" , "4" , "8" , "16" ]; $arrshift = array_shift ( $arr ); print_r ( $arr ); ? >   Output Of Coding Example : 02 => Coding Example : 03 => <?php $arr =[ "Ginny" , "Abhishek" , "Rohaan" ]; $arrshift = array_shift ( $arr ); print_r ( $arr ); ? > Output Of Coding Example : 03 => Q2. What is meant by array_unshift()? Ans: array_unshift() function inserts elements at the beginning of an array. Coding Example : 01 => <?php $arr =[ "1" ,...