Related Topics

what is Protocols in Hindi

What is a Program in Hindi

What is a Secure Connection in Hindi

Introduction to WWW in Hindi

What are Development Tools in Hindi

What is a Web Browser in Hindi

What is a Server in Hindi

What is a UNIX Web Server in Hindi

What is Logging Users in Hindi

What is Dynamic IP Web Design in Hindi

Web Site Design Principles in Hindi

Site Planning in Hindi

Website Navigation in Hindi

what is Web Systems Architecture in Hindi

Architecture of Web-Based Systems in Hindi

Client-Server Architecture in Hindi

What is Caching in Hindi

: Proxies in Hindi

What is an Index in Hindi

What is a Load Balancer in Hindi

What is a Queue in Hindi

Web Application Architecture in Hindi

JavaScript in Hindi

Client-Side Scripting in Hindi

Introduction to Simple JavaScript in Hindi

: JavaScript Variables in Hindi

What is a Function in JavaScript in Hindi

What are Conditions in JavaScript in Hindi

What are Loops in JavaScript in Hindi

What is Repetition (Looping) in JavaScript? in Hindi

What is an Object in JavaScript in Hindi

JavaScript Own Objects in Hindi

DOM in Hindi

What is a Web Browser Environment in Hindi

Forms in JavaScript in Hindi

DHTML in Hindi

What are Events in DHTML in Hindi

Browser Control in JavaScript in Hindi

AJAX in Hindi

AJAX-based Web Application in Hindi

Alternatives to AJAX in Hindi

XML in Hindi

Uses of XML in Hindi

Simple XML in Hindi

XML Key Components in Hindi

What is DTD (Document Type Definition) in Hindi

What is XML Schema (XSD) in Hindi

XML with Application in Hindi

XSL in Hindi

XSLT in Hindi

Web Service in hindi

PHP in Hindi

Server-Side Scripting in Hindi

PHP Functions in Hindi

PHP Forms in Hindi

Advanced PHP Databases in Hindi

Introduction to Basic Commands in PHP in Hindi

Server Connection in PHP in Hindi

Database Creation in PHP in Hindi

Understanding Database Selection in PHP in Hindi

PHPMyAdmin in Hindi

Database Bugs in Hindi

PHP Database Query in Hindi

Related Subjects

PHP Arrays in Hindi

RGPV University / DIPLOMA_CSE / Web Technology

PHP Arrays in Hindi

PHP Arrays एक महत्वपूर्ण concept है जो प्रोग्रामिंग में डेटा को store करने और manipulate करने के लिए इस्तेमाल होता है। Array एक variable होता है, जो कई values को एक साथ store करता है। इस लेख में हम PHP Arrays के बारे में विस्तार से सीखेंगे।

Types of Arrays in PHP in Hindi

PHP में मुख्य रूप से तीन प्रकार के Arrays होते हैं:

  • Indexed Arrays: इस तरह के array में index numbers के द्वारा values को store किया जाता है। इसे numeric index array भी कहा जाता है।
  • Associative Arrays: इस array में values को specific keys द्वारा access किया जाता है, ना कि index numbers द्वारा।
  • Multidimensional Arrays: यह arrays के array होते हैं, जिसमें हम एक array के अंदर दूसरे array को store कर सकते हैं।

Creating Arrays in PHP in Hindi

PHP में Arrays को create करने के लिए दो main methods होते हैं:

  • Using array() function: हम PHP के array() function का उपयोग करके arrays बना सकते हैं।
  • $fruits = array("Apple", "Banana", "Mango");
  • Using Short Array Syntax: PHP 5.4 से पहले से ही short array syntax भी उपलब्ध है।
  • $fruits = ["Apple", "Banana", "Mango"];

Accessing Array Elements in PHP in Hindi

Array elements को access करने के लिए हम array के index या key का उपयोग करते हैं:

  • Indexed Arrays: आप array के index number का उपयोग करके element access कर सकते हैं।
  • echo $fruits[0]; // Output: Apple
  • Associative Arrays: associative array में values को उनके keys के द्वारा access किया जाता है।
  • $person = array("name" => "John", "age" => 30); echo $person["name"]; // Output: John

Modifying Array Elements in PHP in Hindi

Array में किसी भी element को modify करने के लिए हम उसी index या key का उपयोग करते हैं, जिसका उपयोग हम access करने में करते हैं:

  • Indexed Arrays: किसी भी array element को modify करने के लिए index का उपयोग करें।
  • $fruits[1] = "Grapes"; // Array becomes: ["Apple", "Grapes", "Mango"]
  • Associative Arrays: associative array में key के माध्यम से element को modify किया जा सकता है।
  • $person["age"] = 31; // Array becomes: ["name" => "John", "age" => 31]

Array Functions in PHP in Hindi

PHP में Arrays के साथ काम करने के लिए कई built-in functions होते हैं। ये functions arrays को manipulate करने में मदद करते हैं।

  • count(): इस function का उपयोग array के elements की संख्या पता करने के लिए किया जाता है।
  • $count = count($fruits); // Output: 3
  • sort(): इस function का उपयोग array को ascending order में sort करने के लिए किया जाता है।
  • sort($fruits); // Sorts the array
  • array_push(): इस function का उपयोग array के end में एक या ज्यादा elements को add करने के लिए किया जाता है।
  • array_push($fruits, "Orange"); // Adds "Orange" to the end of the array
  • array_pop(): इस function का उपयोग array से आखिरी element को remove करने के लिए किया जाता है।
  • array_pop($fruits); // Removes the last element
  • array_merge(): इस function का उपयोग दो या दो से ज्यादा arrays को merge करने के लिए किया जाता है।
  • $combined = array_merge($fruits, $person); // Merges both arrays

FAQs

Array in PHP is a variable that can hold multiple values. Instead of declaring individual variables for each value, you can store them in an array and access them using indices or keys.

There are three types of arrays in PHP:

  • Indexed Arrays
  • Associative Arrays
  • Multidimensional Arrays

You can create an array in PHP using the array() function or the short array syntax. Example: $fruits = array("Apple", "Banana"); or $fruits = ["Apple", "Banana"];

Array elements can be accessed by using their index (for indexed arrays) or key (for associative arrays). For example:

  • $fruits[0]; for indexed arrays.
  • $person["name"]; for associative arrays.

You can modify array elements by assigning a new value to the array index or key. For example:

  • $fruits[1] = "Grapes";
  • $person["age"] = 35;

Some useful array functions in PHP include:

  • count() - To count the number of elements in an array.
  • sort() - To sort the array in ascending order.
  • array_push() - To add an element to the end of the array.
  • array_merge() - To merge two or more arrays.

Please Give Us Feedback