{"id":18952838,"url":"https://github.com/Sujon-Ahmed/learn-php-function-basic-concept","last_synced_at":"2026-03-29T13:30:20.777Z","repository":{"id":109467686,"uuid":"384032658","full_name":"Sujon-Ahmed/PHP_Function","owner":"Sujon-Ahmed","description":"In this repository, I will practice the PHP function","archived":false,"fork":false,"pushed_at":"2021-09-16T10:00:02.000Z","size":72,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-01T02:41:51.828Z","etag":null,"topics":["array","array-functions","function","math","math-functions","php","php-functions"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Sujon-Ahmed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-08T07:04:17.000Z","updated_at":"2022-07-04T16:14:00.000Z","dependencies_parsed_at":"2023-06-10T08:45:43.158Z","dependency_job_id":null,"html_url":"https://github.com/Sujon-Ahmed/PHP_Function","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujon-Ahmed%2FPHP_Function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujon-Ahmed%2FPHP_Function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujon-Ahmed%2FPHP_Function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Sujon-Ahmed%2FPHP_Function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Sujon-Ahmed","download_url":"https://codeload.github.com/Sujon-Ahmed/PHP_Function/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239952598,"owners_count":19723922,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["array","array-functions","function","math","math-functions","php","php-functions"],"created_at":"2024-11-08T13:34:45.892Z","updated_at":"2026-03-29T13:30:20.722Z","avatar_url":"https://github.com/Sujon-Ahmed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP_Function\n## Table of Contents\n- [trim_function](#trim_function)\n- [implode_function](#implode_function)\n- [explode_function](#explode_function)\n- [is_array_function](#is_array_function)\n- [count_function](#count_function)\n- [substr_function](#substr_function)\n\n### trim_function\nপিএইচপিতে trim() ফাংশন দিয়ে যেকোন স্ট্রিং থেকে স্পেস কিংবা যেকোন অক্ষর/ক্যারেক্টার মুছে দেয়া যায় (স্ট্রিংটির শুরু কিংবা শেষ থেকে)।\n    - [Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/01.trim_%20function/index.php)\n\n### implode_function\nimplode() ফাংশন দিয়ে অ্যারের এলিমেন্টগুলিকে জোড়া দিয়ে স্ট্রিং বানানো যায়।\n    - [Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/02.imolode_function/index.php)\n\n### explode_function\nপিএইচপিতে explode() ফাংশন দিয়ে একটা স্ট্রিংকে একটা ক্যারেক্টার বা স্ট্রিং দিয়ে ভাগ করে অ্যারে বানানো যায়। এই ফাংশনটি implode() এর বিপরীত।\n    -[Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/03.explode_function/index.php)\n\n### is_array_function\nis_array() ফাংশন দিয়ে পিএইচপিতে একটা ভেরিয়েবল অ্যারে কিনা সেটা চেক করা যায়। \n    -[Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/04.is_array_function/index.php)\n\n### count_function\nপিএইচপিতে অ্যারের এলিমেন্ট সংখ্যা বের করতে (গুনতে) count() ফাংশন ব্যবহার করা হয়।\nফাংশনটি অ্যারের এলিমেন্ট গুনে সেই সংখ্যাটি (integer) রিটার্ন করবে।\n১ম প্যারামিটার $array_or_countable এখানে যে অ্যারেটি গুনতে চান সেটার দিতে হবে। অ্যারে ছাড়াও অবজেক্টের কিছু জিনিস গুনতে পারে তবে মুলত অ্যারের এলিমেন্ট গুনতেই এটা বেশি ব্যবহার হয়। প্যারামিটারটির সামনে mixed এজন্য দেয়া হয়েছে যে, প্যারামিটারটি একটি অ্যারেও হতে পারে আবার একটি অবজেক্টও হতে পারে। ২য় প্যারামিটার বাই ডিফল্ট COUNT_NORMAL এটা থাকে। এটা ছাড়া COUNT_RECURSIVE দিতে পারেন। মাল্টিডাইমেনশনাল অ্যারে count এর জন্য এটা দিতে হয়।\nমাল্টিডাইমেনশনাল অ্যারে count (COUNT_RECURSIVE প্যারামিটারের ব্যবহার)\n\u003cpre\u003e\n\u003ccode\u003e\n$continents = array(\n3.\n\"Asia\" =\u003e array(\"Bangladesh\",\"India\",\"Pakistan\"),\n4.\n\"Europe\" =\u003e array(\"England\",\"France\"),\n5.\n\"Africa\" =\u003e array(\"Kenya\",\"Libya\",\"Somalia\")\n6.\n);\n7.\necho count($continents,COUNT_RECURSIVE);\n\u003c/code\u003e\n\u003c/pre\u003e\nOutput : 11\nএখানে COUNT_RECURSIVE না দিলে আউটপুট 3 দেখাত কারন তখন সাবঅ্যারেগুলির এলিমেন্ট count করতনা।\n   -[Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/05.count_function/index.php)\n\n### substr_function\nপিএইচপিতে একটা স্ট্রিং থেকে নির্দিষ্ট কোন অংশ বের করার দরকার হলে substr() ফাংশন ব্যবহার করা হয়।\u003cbr\u003e  \nডেমো প্যারামিটারসহ সংকেত \u003cbr\u003e\n\u003cpre\u003e\n\u003ccode\u003estring substr(string $string, int $start[, int $length])\u003c/code\u003e\n\u003c/pre\u003e\nফাংশনটি পরিবর্তিত স্ট্রিংটি রিটার্ন করবে।\n\n\u003cb\u003e১ম প্যারামিটার\u003c/b\u003e স্ট্রিং হবে যেটা থেকে তার কোন অংশ আলাদা করতে চাচ্ছেন (স্ট্রিংটি অবশ্যই কমপক্ষে এক অক্ষরের বা ক্যারেক্টারের হতে হবে)।\n\n\u003cb\u003e২য় প্যারামিটার\u003c/b\u003e পূর্নসংখ্যা হবে। এখানে দিতে হবে ঐ সংখ্যা যে পজিশন থেকে স্ট্রিংটির ক্যারেক্টার আলাদা করতে চাচ্ছেন। 0 থেকে শুরু হবে। যেমন \"sujonahmed\" স্ট্রিংটির 0 পজিশনের ক্যারেক্টার/অক্ষর হচ্ছে \"s\", 1 নম্বর পজিশনের ক্যারেক্টার হল \"u\" এভাবে...। যদি এই প্যারামিটারটির ($start) মান ঋনাত্নক দেন তাহলে উল্টো দিক থেকে শুরু হবে এবং ঐ সংখ্যা পরিমান ক্যারেক্টার আলাদা করে সেটা রিটার্ন করবে। \u003cbr\u003e\n\u003cstrong\u003eExample\u003c/strong\u003e\n\u003cpre\u003e\n\u003ccode\u003e\n    $x = \"sujonahmed\";\n    echo substr($x,1);\n\u003c/code\u003e\n\u003c/pre\u003e\nResult : ujonahmed \u003cbr\u003e\n$start এর মান ১ দেয়াতে ১ নম্বর ক্যারেক্টার থেকে শুরু করে বাকি ক্যারেক্টারগুলি সহ স্ট্রিংটি রিটার্ন করছে। যদি মান -2 দিতাম তাহলে \"sujonahmed\" স্ট্রিংটির ডানদিক থেকে গননা শুরু হবে এবং আউটপুট হবে \"ed\", -3 দিলে আউটপুট ৩টি ক্যারেক্টার আসবে \"med\" এভাবে... \u003cbr\u003e\n\n\u003cb\u003e৩য় প্যারামিটার\u003c/b\u003e $length হল কতটি ক্যারেক্টার তুলে আনতে চান সেটার সংখ্যা, এটা ঐচ্ছিক প্যারামিটার তাই বাই ডিফল্ট $start থেকে পরেরগুলি সব তুলে আনে। আর যদি সব না লাগে তাহলে যতটি লাগবে সেই সংখ্যা $length এর স্থলে দিতে হবে।\n\nযেমন আমি যদি \"sujonahmed\" স্ট্রিংটির ৩ নম্বর ক্যারেক্টার/অক্ষর থেকে নিয়ে এরপরের ২টি ক্যারেক্টার তুলে আনতে চাই তাহলে \u003cbr\u003e\n\u003cstrong\u003eExample\u003c/strong\u003e\n\u003cpre\u003e\n\u003ccode\u003e\n    $x = \"sujonahmed\";\n    echo substr($x,2,2);\n\u003c/code\u003e\n\u003c/pre\u003e\nResult : jo\n\u003cbr\u003e\nযদি $length এর মান ঋনাত্নক দেন তাহলে ঐ সংখ্যা পরিমান ক্যারেক্টার শেষ থেকে বাদ দিবে। \u003cbr\u003e\n\u003cstrong\u003eExample\u003c/strong\u003e\n\u003cpre\u003e\n\u003ccode\u003e\n    $x = \"sujonahmed\";\n    echo substr($x,2,-3);\n\u003c/code\u003e\n\u003c/pre\u003e\nআউটপুট (-3 দেয়াতে শেষ থেকে ৩টি ক্যারেক্টার med বাদ দিয়েছে এবং ২ নং পজিশন থেকে ক্যারেক্টার নেয়া শুরু করেছে) \u003cbr\u003e\nResult : jonah \u003cbr\u003e\n\u003cstrong\u003e** $length এর মান 0, FALSE বা NULL দিলে ফাকা স্ট্রিং রিটার্ন করবে।\u003c/strong\u003e\n** যদি $string (১ম প্যারামিটার) এ যে পরিমান ক্যারেক্টার আছে তার চেয়ে বেশি $start (২য় প্যারামিটারের) এর মান দেন তাহলে false রিাটর্ন করবে। এমনকি সমান হলেও false রিাটর্ন করবে। যেমন\n\u003cbr\u003e\n\u003cpre\u003e\n\u003ccode\u003e\n    $x = \"sujonahmed\";\n    echo substr($x,10);\n\u003c/code\u003e\n\u003c/pre\u003e\nResult : bool(false)\n\u003cbr\u003e\n\n-[Source_Code](https://github.com/Sujon-Ahmed/PHP_Function/blob/main/06.substring_function/index.php)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSujon-Ahmed%2Flearn-php-function-basic-concept","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSujon-Ahmed%2Flearn-php-function-basic-concept","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSujon-Ahmed%2Flearn-php-function-basic-concept/lists"}