what are Implode and Explode functions?




Answers were Sorted based on User's Feedback



what are Implode and Explode functions?..

Answer / -=pkg=-

The implode() function takes an already existing array as
it's argument, and concatenates the contents of
each element in the array into a string.

where as explode() function performs reverse to implode()
function. It splits the string into items by a
delimiter, such as a dash, ampersand, space and places each
item into a new array.

Is This Answer Correct ?    52 Yes 8 No

what are Implode and Explode functions?..

Answer / puneet bhatt

explode function:-it breaks a string into array.
<?php
$str="hello world.it's a beautiful day.":
print_r(explode(" ",$str):
?>
ans-ARRAY
[0]=>hello
[1]=>world.
[2]=>it's
[3]=>a
[4]=>beautiful
[5]=>day.

implode:-returns a string from elements of an array.
<?php
$arr=array('hello','world!',beautiful,'day!');
echo implode(" ",$arr);
?>
ans-hello world! beautiful day!

Is This Answer Correct ?    35 Yes 5 No

what are Implode and Explode functions?..

Answer / inno dev

explode= convert string into an array
such as
$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0];
echo $pieces[1];
echo $pieces[2];
echo $pieces[3];
echo $pieces[4];
echo $pieces[5];

Implode=Join array elements with a string
means convert array into a string

such as
<?php

$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);

echo $comma_separated;
?>

Is This Answer Correct ?    22 Yes 2 No




what are Implode and Explode functions?..

Answer / suraj raut paul

Implode()
this just concatenate the variables and placed into one single variable for example
<form action=<?php $_php_self; ?> method="post">
<label for="dob">Enter Your date of Birth</label>

<select name="day">Day</option>
<option value="1">sun</option>
<option value="2">mon</option>
</select>
<select value="month">Month
<option value="1">Jan</option>
<option value="2">feb</option>
</select>

<select name="year">year
<option value="2012">2012</option>
<option value="2011">2011</option>
</select>

when sending this value in database in single field then you need to join all the values in single variable that is
$dob= implode(array($_post['day'], $_post['month', $_post['year']));

Then it's just concatenated all these values come from the from into single variable $dob.

Explode()
this is the function that is just reverse of the implode.
that it's just split the value given in one varible into array.

Is This Answer Correct ?    6 Yes 0 No

what are Implode and Explode functions?..

Answer / jhon

Implode and Explode are function sthat are opposite in working
Explode converts a string into array where as implode
coverts an array in string
explode example

<?php
$str = "test explode in php";
print_r (explode(" ",$str));
?>
output will be:
Array
(
[0] => test
[1] => explode
[2] => in
[3] => php
)
implode example


<?php
$arr = array('hi','hello');
echo implode(" ",$arr);
?>
output will be:
hi hello

Is This Answer Correct ?    6 Yes 1 No

what are Implode and Explode functions?..

Answer / kalaimani.k mca (gurunanak col

Example . explode()

<?php
$history= "php4 php5 php6";
$pieces = explode(" ", $history);

//separated the arrays

echo $history[0]; // php3
echo $history[1]; // php4
echo $history[1]; // php5
?>

//implode Join array elements with a string

implode() example
<?php
$array = array('lastname', 'email', 'phone');
$comma_separated = implode(",", $array);
echo $comma_separated;

//lastname,email,phone

Is This Answer Correct ?    4 Yes 1 No

what are Implode and Explode functions?..

Answer / jaimin

Explode function is use to convert string into an array and
Implode function is use to convert an array into string.

Is This Answer Correct ?    2 Yes 2 No

what are Implode and Explode functions?..

Answer / ajay dabhi

Explode function converts comma separated string value into
array

Implode function converts array into comma separated string

Is This Answer Correct ?    22 Yes 24 No

Post New Answer



More PHP Interview Questions

How can I rotate an image?

1 Answers   Rushmore Consultancy,


What is the maximum size of a file that can be uploaded using PHP and how can we change this?

4 Answers  


Difference between notify url, return url in paypal payment gateway?

4 Answers   A1 Technology, Capital IQ, CMS, Essar, HCL, IAS, Karvy, L&T, TATA, Tisco, WNS, State Bank Of India SBI,


hi, i have knowledge about PHP/MYSQL,i am fresher M.Sc-IT 2009 pass out,any recruitment in PHP please let me know.

0 Answers  


what is interface in php? how it is use?

10 Answers   Infosys, Wipro, Torque Infotech, PHP, Times,






How i can integrate merchant payment get way in zen cart? in php? plz help me

1 Answers   BA Continnum Solutions,


How can we send mail using JavaScript?

13 Answers   dwise, iScope,


hello myself Atul saini completed mca in 2007 due to personal problem i cant do job.now i really search 4 a job.i dont know where i go i think simple think is learn php anyone help me wat i can do for a job. thanks

4 Answers  


This question is regarding version control. If two developers are committing the same php file at same time what will happen ? What error it will show (if any) ?

2 Answers   TCS,


how to run PHP in command line?

8 Answers   Xtreeme, InfoShore, Ramp Green,


Is PHP is procedure oriented or object oriented?

10 Answers   DLF, Net Solution,


Write a function that takes "depth" as argument and return sum of node's data of that depth. For instance, (0) depth 0 / \ (10) (20) depth 1 / \ (40) (50) depth2 If I pass get_sum_by_depth(2) , it would return 90 (i.e. 40 + 50 )

0 Answers   Amazon,






Categories