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 ?    36 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 ?    9 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

Is age interval or ordinal data?

0 Answers  


How to check an key is exists in array?

0 Answers  


What are the differences between procedure-oriented languages and object-oriented languages?

6 Answers   ASD Lab, DewSoft,


What are the benefits of using php and mysql?

0 Answers  


How to create a public static method in PHP?

0 Answers  






For printing out strings, there are echo, print and printf. Explain the differences.

3 Answers  


How can you execute php script from the command line?

0 Answers  


What are the differences between require and include, include_once?

3 Answers  


when we select some checkboxes and we went for next page if we came back to prevoius page the selcted checkboxe should be checked

2 Answers  


Why do you need to filter out empty files?

0 Answers  


What is php in full?

0 Answers  


What is query string php?

0 Answers  


Categories