ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Explain the difference of extract() ,explode() and implode() ?

user-image
تم إضافة السؤال من قبل Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
تاريخ النشر: 2016/01/11
Abdul Rehman Anwer
من قبل Abdul Rehman Anwer , Developer , Creative Advertising

In PHP these3 builtin functions are related to array. So I'll try to give you an idea about three of these functions below.

1 : extract() .. This function takes array and converts them into local variables from array keys. here is an example.

$cities = array( 'a' => 'Dubai', 'b' => 'Islamabad', 'c' => ' Mambai' );

extract( $cities );

echo $a;

echo '<br />';

 

echo $b;

echo '<br />';

 

echo $c;

echo '<br />';

The Output :

Dubai

Islamabad

Mambai

2:  implode() .. This function returns a string from the elements of an array. assuming that we are working with the above array.

echo implode( $cities )'

out put will be :

Dubai Islamabad Mambai.

3 : explode() .. This function somewhat works against implode(). and it breaks a strings into an array.

$string = 'Hello Bayt, I am a string';

print_r (explode(" ",$string));

The Output:

array( [0] => Hello [1] => Byat, [2] => I [3] => am [4] => a [5] => string )

مستخدم محذوف‎
من قبل مستخدم محذوف‎

Implode: to collapse inward in a very sudden and violent way

Explode:to expand with force and noise because of rapid chemical change or decomposition

Extract to get, pull, or draw out, usually with special effort, skill, or force

المزيد من الأسئلة المماثلة