PHP অ্যারে সার্ট
- Previous Page PHP অ্যারে
- Next Page PHP Super Global
বিন্যাসের তথ্য শব্দ বা সংখ্যার অনুযায়ী ক্রমবর্ধমান বা ক্রমহীন ক্রমানুসারে বিন্যাস করা যেতে পারে。
PHP - বিন্যাস ফাংশন
এই সেকশনে, আমরা নিম্নলিখিত PHP বিন্যাস ফাংশনগুলো শিখব:
- sort() - ক্রমবর্ধমান ক্রমানুসারে বিন্যাস করা
- rsort() - ক্রমহীন ক্রমানুসারে বিন্যাস করা
- asort() - মূল্য অনুযায়ী ক্রমবর্ধমান ক্রমানুসারে সংযুক্ত বিন্যাস করা
- ksort() - কী অনুযায়ী ক্রমবর্ধমান ক্রমানুসারে সংযুক্ত বিন্যাস করা
- arsort() - মূল্য অনুযায়ী ক্রমহীন ক্রমানুসারে সংযুক্ত বিন্যাস করা
- krsort() - কী অনুযায়ী ক্রমহীন ক্রমানুসারে সংযুক্ত বিন্যাস করা
বিন্যাস - ক্রমবর্ধমান ক্রমানুসারে বিন্যাস করা
নিচের উদাহরণে, $cars এর তথ্য বিন্যাস করে শব্দের অক্ষর বর্ণের অনুযায়ী ক্রমবর্ধমান করা হয়:
Example
<?php $cars=array("porsche","BMW","Volvo"); sort($cars); ?>
The following example sorts the elements of the array $numbers in ascending order by number:
Example
<?php $numbers=array(3,5,1,22,11); sort($numbers); ?>
Sort the array in descending order - rsort()
The following example sorts the elements of the array $cars in descending order by letter:
Example
<?php $cars=array("porsche","BMW","Volvo"); rsort($cars); ?>
The following example sorts the elements of the array $numbers in descending order by number:
Example
<?php $numbers=array(3,5,1,22,11); rsort($numbers); ?>
Sort the array by value in ascending order - asort()
The following example sorts the associated array in ascending order by value:
Example
<?php $age=array("Bill"=>"63","Steve"=>"56","Elon"=>"47"); asort($age); ?>
Sort the array by key in ascending order - ksort()
The following example sorts the associated array in ascending order by key:
Example
<?php $age=array("Bill"=>"63","Steve"=>"56","Elon"=>"47"); ksort($age); ?>
Sort the array by value in descending order - arsort()
The following example sorts the associated array in descending order by value:
Example
<?php $age=array("Bill"=>"63","Steve"=>"56","Elon"=>"47"); arsort($age); ?>
Sort the array by key in descending order - krsort()
The following example sorts the associated array in descending order by key:
Example
<?php $age=array("Bill"=>"63","Steve"=>"56","Elon"=>"47"); krsort($age); ?>
Complete PHP Array Reference Manual
For a complete reference manual of array functions, please visit our PHP Array Reference Manual.
This reference manual includes a brief description and usage examples of each function.
- Previous Page PHP অ্যারে
- Next Page PHP Super Global