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 we know the number of days between two given dates using PHP?

8 Answers   HCL, AZTEC, Navsoft,


How to add a cookie?

2 Answers  


How many ways I can redirect a PHP page?

9 Answers   MicroSec, University Exams, N-Tier Business Solutions,


How can we create a database using PHP and mysql?

3 Answers  


i want to store retrieved data from database into an array list with limit.And display the data from that array list.have any answer for this?

2 Answers  






when you will get the message/error "headers already sent"?

5 Answers  


how to upload more than 50 mb? i tried but session was expired....certain time .....i was set session duration three days .... how to rectified? if any one know that post ur answer as soon as possible?already i was increase php.ini and set Also increase Memory_limit Post_max_size upload_max_filesize..........but not working......

0 Answers  


Whhat is a Functions

1 Answers   IQ,


i got this error msg in online... how to solve this problem... i couldnot find out as soon as possible send me answer or idea COULD NOT ABLE TO CONNECT DATABASE . Can't connect to local MySQL server through socket '/usr/local/mysql-5.0/data/mysql.sock' (2)

3 Answers   Quest,


write the prime number of program?in php

2 Answers   TCS,


just explain MYSql ISAM and InnoDB functions. and what is the diffrent between both. and which is the better in both.

2 Answers  


What is the difference between ereg_replace() and eregi_replace()?

2 Answers   Quicknet,






Categories