আমাদের পিএইচপি 7-এ নিম্নলিখিত ধরণের ধ্রুবক অ্যারে রয়েছে -
- ধ্রুবক বিন্যাসের মিলন
- ধ্রুবক অ্যারেগুলির সমতা
- ধ্রুবক অ্যারেগুলির পরিচয়
- ধ্রুবক অ্যারেগুলির অসমতা
ইউনিয়ন ধ্রুবক অ্যারে (+)
ইউনিয়ন ধ্রুবক অ্যারে দুটি অ্যারেতে যোগ দিতে প্লাস চিহ্ন (+) ব্যবহার করে। দুটি অ্যারের যোগদান সূচক স্তরে সঞ্চালিত হয়। উদাহরণস্বরূপ, আমরা দুটি অ্যারে নেব, x, এবং y। অ্যারে x এর চারটি উপাদান রয়েছে এবং অ্যারে y এর পাঁচটি উপাদান রয়েছে। এখন, আমরা print_r($x+$y) ব্যবহার করে x এবং y অ্যারে একত্রিত করব।
উদাহরণ
<?php $x = array(11, 12, 13,14); $y = array('Rohan','Mohan','Thomas','John','Alex'); define('rollno',$x); define('Stud_Name',$y); print_r("The union of the arrays are:"); print_r($x+$y); define('College','rollno','Stud_Name'); print("The constant array of rollno is at index 3 is:"); print(rollno[3]); print("The constant array of Stud_name is at index 2 is:"); print(Stud_Name[4]); print("The constant array of college is at index 4 is:"); print(College[4]); ?>
আউটপুট
উপরের প্রোগ্রামের আউটপুট হবে −
The union of the arrays are: Array ( [0] => 11 [1] => 12 [2] => 13 [3] => 14 [4] => Alex ) The constant array of rollno is at index 3 is:14 The constant array of Stud_name is at index 2 is:Alex The constant array of college is at index 4 is:Alex
ধ্রুবক অ্যারেগুলির সমতা (==)
ধ্রুবক অ্যারেগুলির সমতা প্রদত্ত অ্যারের সমতা খুঁজে পেতে সমান (==) অপারেটর নেয়। সমান অপারেটর সূচক স্তরের অ্যারেতে পাশাপাশি উপাদানের মানগুলিতে ব্যবহার করে। ধরুন আমাদের দুটি ভিন্ন অ্যারে আছে, x এবং y, 4 এবং 5 উপাদান সহ। তারপর, আমরা ($x==$y) ব্যবহার করে x এবং y অ্যারের মধ্যে সমতা পরীক্ষা করব। যদি প্রদত্ত অ্যারে সমান হয়, তাহলে এটি সত্য হবে এবং উভয় অ্যারে সমান না হলে, এটি মিথ্যা ফেরত দেবে।
উদাহরণ
<?php $x = array(11, 12, 13,14, 15); $y = array('Rohan','Mohan','Thomas','John','Alex'); define('rollno',$x); define('Stud_Name',$y); print_r("The equality of the rollno arrays are:"); var_dump('rollno'=='rollno'); //using equality operator and result will be true print_r("The equality of the arrays are:"); var_dump('rollno'=='Stud_Name'); //using equality operator and result will be true ?>
আউটপুট
উপরের প্রোগ্রামের আউটপুট হবে −
The equality of the rollno arrays are:bool(true) The equality of the arrays are:bool(false)
কনস্ট্যান্ট অ্যারেগুলির পরিচয় (===)
পরিচয় (===) অপারেটরটি প্রদত্ত অ্যারেগুলি অভিন্ন কিনা তা পরীক্ষা করতে ব্যবহৃত হয়। ধরুন আমাদের দুটি ধ্রুবক অ্যারে আছে, x এবং y। যদি উভয় প্রদত্ত অ্যারে একই কী এবং মান জোড়া ব্যবহার করে যা একই প্রকার এবং একই ক্রমে হয়। তাহলে ফলাফল সত্য হবে অন্যথায় ফলাফল মিথ্যা হবে।
উদাহরণ
<?php $x = array('Rohan','Mohan','Thomas','John','Alex'); define('Stud_Name',$x); print_r("The identity of the Stud_Name arrays are:"); var_dump('Stud_Name'==='Stud_Name'); // Used identity (===) operator ?>
আউটপুট
উপরের প্রোগ্রামের আউটপুট হবে −
The identity of the Stud_Name arrays are:bool(true)
ধ্রুবক অ্যারেগুলির অসমতা (!=)
প্রদত্ত দুটি অ্যারে সমান কি না তা পরীক্ষা করতে অসমতা অপারেটর ব্যবহার করা হয়। অসমতা সূচক স্তরের অ্যারে এবং অ্যারের উপাদানগুলির মানগুলিতে সঞ্চালিত হবে৷
ধরুন আমাদের দুটি অ্যারে আছে, x এবং y। অ্যারে x এর চারটি উপাদান রয়েছে এবং অ্যারে y এর পাঁচটি উপাদান রয়েছে, তারপর আমরা x এবং y অ্যারের মধ্যে অসমতা পরীক্ষা করব। উদাহরণস্বরূপ, যদি $x!=$y হয়, ফলাফলটি সত্য হবে কারণ x এবং y এর মান মেলে না।
উদাহরণ
<?php $x = array(11, 12, 13,14, 15); $y = array('Rohan','Mohan','Thomas','John','Alex'); define('rollno',$x); define('Stud_Name',$y); print_r("the equality of the rollno arrays are:"); var_dump('rollno'!='rollno'); print_r("the equality of the arrays are:"); var_dump('rollno'!='Stud_Name'); ?>
আউটপুট
উপরের প্রোগ্রামের আউটপুট হবে −
The equality of the rollno arrays are:bool(false) The equality of the arrays are:bool(true)