PHP Arrays

PHP Arrays In Hindi – Arrays In Hindi

PHP

PHP Arrays In HindiArray In Hind in PHP – Array Ka Ek Different Type Ka Variable Hain Jo Different Values ( Items ) Ko Store Kar Sakta Hain | Dusre Word Main Kahe to Array Ek Special Type Ka Variable Hai Jisme Different Variables Ho Sakte Hain | Arrays Ek Same Data Type Ke Bahut Sare Values Ko Store Kar Sakta Hain Ek Sath |

PHP Arrays In Hindi

Array ye same data type ke variables ka collection hota hain
PHP Array in Hindi ko samanjh ne ke liye ham examples ko dekhte hai.

Array ko isliye istemal karte hai agar kisi ek student ka sab data stored karna ho to keval ham array ki help se keval ek hi variable banayenge.

PHP Main Array Ko Create Karne Ke LIye array() Function Ka Istemal Kiya Jata Hain |

For Example :-
$stud1 = array(“Danish” , stud2 = “azhar”, stud3 = “Ali” );

  • Array ka data type koi sa bhi ho sakta hai.
  • Array ke variables aapne pass wale memory location par stored hota hai.
  • Array ka pahla value 0 se start hota hai.
  • Array Ka Pahla Memory Address Sabse Kam Hota hai.

Types Of Array in PHP in Hindi

  • Indexed arrays
  • Associative Array
  • Multi-Dimensional Array

Indexed array in PHP In Hindi

PHP Index Array Number 0 Se Start Hote Hain And Ham PHP Index Array Main Number, String, object Ko Store Kar Sakte Hain | Ye Sabhi Items Index Array Main Alag Alag Index Number Ke Sath Hote Hain |

Memory Representation

Syntax :

$array_name = array(Values);
$num = array();

Syntax for Initialization

$array_name = array(value1, value2,...,value n);
echo $array_name[0]; // index number

Example:

<?php
$num = array(1,2,3,4,5);
echo "$num[0] <br> $num[1] <br> $num[4]";  // index array
?>

Output:

1
2
5  

Read Full :- Indexed Arrays In PHP

Associative Array in PHP In Hindi

PHP Associative Array in Hindi – Associative Array Sabse Acche array Hota Hain. Associative Array Mai Ham => (equal = and angel > ) Symbol Ka Istemal Karte Hain |

Associative Array Ki Help Se Aap Kisi Bhi Key Or Koi Bhi Value Assign Kar Sakte Hain | Associative Array Key Or Value (=>) Par Depend Karta Hain |

Syntax:

key=>value

Example:

<?php
$student_roll = array("Danish"=>44 ,"Azhar" => 54);
echo $student_roll['Danish'];
echo "<br>";


foreach($student_roll as $x => $x_value) {
  echo "Key=" . $x . ", Value=" . $x_value;
  echo "<br>";
  
?>

Output:

44
  
Key= Danish, Value= 44
Key= Azhar, Value= 54 

Read Full :- Associative Array In PHP

Multi-Dimensional Array in PHP In Hindi

Jisme Sirf 2 ya 2 se jyada Subscript Hoti Hai Use Two Ya Multi-Dimensional Arrays Kahte Hai | Iska Pryog Matrix Ya Table (Row And Column ) Ke Rup Mai Hota Hai |

Syntax

$array_name = array(row 
array(column),
);

Syntax for Initialization

$cars = array (
  array("Volvo",22,18),
  array("BMW",15,13),
  array("Saab",5,2),
  array("Land Rover",17,15)
);

Memory Representation

array in c Hindi
2 array in c

Example : 

<?php
$cars = array (
  array("Volvo",22,18),
  array("BMW",15,13),
  array("Saab",5,2),
  array("Land Rover",17,15)
);
  
echo $cars[0][0].": In stock: ".$cars[0][1].", sold: ".$cars[0][2].".<br>";
echo $cars[1][0].": In stock: ".$cars[1][1].", sold: ".$cars[1][2].".<br>";
echo $cars[2][0].": In stock: ".$cars[2][1].", sold: ".$cars[2][2].".<br>";
echo $cars[3][0].": In stock: ".$cars[3][1].", sold: ".$cars[3][2].".<br>";
?>

Output:

Volvo: In stock: 22, sold: 18.
BMW: In stock: 15, sold: 13.
Saab: In stock: 5, sold: 2.
Land Rover: In stock: 17, sold: 15.

Example 2:

 
      <?php
         $marks = array( 
            "mohammad" => array (
               "physics" => 35,
               "maths" => 30,	
               "chemistry" => 39
            ),
            
            "qadir" => array (
               "physics" => 30,
               "maths" => 32,
               "chemistry" => 29
            ),
            
            "zara" => array (
               "physics" => 31,
               "maths" => 22,
               "chemistry" => 39
            )
         );
         
         /* Accessing multi-dimensional array values */
         echo "Marks for mohammad in physics : " ;
         echo $marks['mohammad']['physics'] . "<br />"; 
         
         echo "Marks for qadir in maths : ";
         echo $marks['qadir']['maths'] . "<br />"; 
         
         echo "Marks for zara in chemistry : " ;
         echo $marks['zara']['chemistry'] . "<br />"; 
      ?>

Output:

Marks for mohammad in physics : 35
Marks for qadir in maths : 32
Marks for zara in chemistry : 39

Read Full :- Multi-Dimensional Array In PHP

Also Read:

Dosto mujhe ummed hai ki aap array in PHP in Hindi  ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre or ha agar aap video bhi dekhna chahte hai to aap mere channel ko bhi subscribe kar sakte hai. channel ka link aapko home page par mil jayega |

Leave a Reply

Your email address will not be published. Required fields are marked *