PHP implode() and explode() function in hindi

php implode and explode funciton in hindi

Introduction

हेलो दोस्तों आज हम इस post में explode() और implode() function के बारे में जानेगे. explode() और implode() दोनो string function है!. दोनों function का इस्तेमाल अगर हमें किसी string को array के formate convert करना हो या array को एक string formate में set करना हो तो php में हम इन दोनों function का अपने program में इस्तेमाल कर सकते है!.

PHP string function

1.explode()
2.implode()

Implode() function

php में Implode() function का इस्तेमाल किसी array को string में convert करने के लिए किया जाता है!.

syntax:

implode(separator,array)

Example:

<?php
 $arr = array('php','html','jquery','css','javascript');
 $res = implode( "  " , $arr );
 print_r( $res );
?>

output:

php html jquery css javascript

ऊपर के example में देख सकते है की हमने array( “php”,”html”,”jquery”,”css”,”javascript” ) array बनाया है. और इस array को string में convert करने के लिए हमने implode() function का इस्तेमाल किया हैi. implode function में दो parameter set करना होता है पहले है वह separator parameter अगर array को string में convert करने के बाद जो sting का output होगा वह किस separator के साथ show होंगे वह define करता है अगर separator में हम ” + “ और ” | “ और दूसरे किसी बी operator का इस्तेमाल करते है तो वह string में show होता है. अगर separator में space set करते है तो वह string के word space के साथ show होंगे.


Explode() function

php में Explode() function का इस्तेमाल किसी string को array में convert करने के लिए किया जाता है!.

syntax:

explode(separator,string,limit)

Example:

<?php

//implode function example

$string = "Hello this is techical website";

$res = explode(" ",$string);

echo "<pre>";

print_r( $res );

?>

output:

Array
(
    [0] => Hello
    [1] => this
    [2] => is
    [3] => techical
    [4] => website
)

ऊपर के एक्साम्प्ले में देख सकते है की हमने एक string सेट की है “Hello this is techical website” . और इस string को array में convert करने के लिए हमने explode() function का इस्तेमाल किया है. explode function में दो parameter set करना होता है पहले है वह separator parameter अगर string breack करनी है तो string में word के bith में जो common होगा उससे हम string को breack कर सकते है .“Hello this is techical website” इस string में हर एक word के बाद space अति है तो हम string को space के साथ breack कर सकते है. और string space breack होने के बाद हर एक word array की index में assign हो जायेगा जैसे की “Hello” word है वह array[0] index पे और “this” है वह array[1] index में assing होगा तो इस तरह string का हर word array के index में store होगा.

Leave a Comment

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