Questions tagged [implode]

implode() is a PHP function that joins together an array (optionally based on a 'glue' (inverse delimiter)) and returning a string.

implode() is a PHP function that joins together an array (optionally based on a 'glue' (inverse delimiter - defaults to an empty string) and returning a string.

string implode ( string $glue , array $pieces )
string implode ( array $pieces )

Example

$array = array("a", "b", "c", "d");
print_r(implode(" ", $array));
print_r(implode($array));

returns:

a b c d
abcd
749 questions
-2
votes
1 answer

PHP array comma separated string

I have a question. I try to separate the output from my MySQL database with a comma. Somehow that doesn't work. PHP code: echo "["; if ($result = $con->query("SELECT * FROM table")) { while($row = $result->fetch_array(MYSQLI_ASSOC)) { …
Mi Wi
  • 1
  • 2
-2
votes
1 answer

Converting numeric array to associative array using implode or explode?

So lets say I have an array and when I var_dump(); it, it has the following output: [1]=> string(20) "Name: Kevin" [2]=> string(20) "Age: 20" Can I manipulate it using implode or explode so that the output would look like…
Tenka
  • 31
  • 6
-2
votes
7 answers

PHP Implode address losing last part of address

I have the following code, which takes a location and extracts the city and state/country out of it: $address_input = "555 Test Drive, Johannesburg, South Africa"; if (strpos($address_input, ',') !== false) { $arr = explode(", ",…
cpcdev
  • 1,130
  • 3
  • 18
  • 45
-2
votes
1 answer

IN with multiple value

I want to search multiple values from database field. below is my query. For example _$Shape = Makeable2,Clivage Brn_ ; _$Color = GHI,JKL_ SELECT * FROM inventory WHERE Shape IN ($Shape) OR Color IN ($Color)
-2
votes
2 answers

implode value does not count as an array

So this is my code for set the date from selected date to auto set date excluding weekend (sat&sun) and holiday ( i put it in database ) : function number_of_working_dates($from, $days) { /* get holiday from database */ …
Kiki Nice
  • 29
  • 1
  • 7
-2
votes
1 answer

Trouble with imploded array and string concatenation in SQL condition

I have little question. I have imploded array ($imploded_arr) . I want use it in SQL condition with next variable ($godz). It looks something like that: r3.meta_key LIKE '$imploded%$godz' . But it not works. Probably something wrong is with…
Derizen
  • 1
  • 5
-2
votes
1 answer

PHP Warning: implode()

I'm getting the error below... HP Warning: implode() [function.implode]: Argument must be an array if (!empty($_FILES) && in_array('adjunto', array_keys($_FILES) ) ) { $mail->AddAttachment(…
-2
votes
4 answers

How to implode array data from index 2

I have array data like this : $word[0]="search"; $word[1]="journal"; $word[2]="information"; $word[3]="system"; If I make PHP code like this : $output=implode(" ",$word); The output (implode result) is a combination of word ("search journal…
Atina
  • 17
  • 6
-2
votes
4 answers

php array to comma separated string implode issues

I'm having a problem in imploding an array to comma separated with double quotation. My Script is as below:
Shiv Singh
  • 6,939
  • 3
  • 40
  • 50
-2
votes
1 answer

how to erase extra space coming in implode function

i have made an implode function. but in that some space is coming. Due to that my output is not coming correctly. like: $category={"Software Developer",".Net Developer", "Android Developer"} $cat= "'".implode("','",$category)."'"; …
Priyanka
  • 75
  • 1
  • 12
-2
votes
3 answers

how to put comma separated words into array

I have an array which i have converted into comma separated here is how I did it: $array[] = $imp; $strings = implode(", ", $array); After implode I get 34, 56, 78. Now I have an array stored in session and I want to add $strings into it…
Aniket Singh
  • 857
  • 4
  • 16
  • 39
-2
votes
2 answers

Creating a string from a Php array and writing it to a text file

I have an array like this: Array ( [0] => firstname1, [1] => lastname1, [2] => firstname2, [3] => lastname2, [4] => firstname3, [5] => lastname3 ) Now I want to create a text file containing this…
stack
  • 10,280
  • 19
  • 65
  • 117
-2
votes
2 answers

using data outside while-loop

I am using this code which calls the period_id : $cart = $this->GetUserCart(); $dataset = array(); while ($data = $cart->fetch_array()) { $dataset[] = $data['period_id']; } so I need to implode the result so they can be separated by comma $p…
Fin del Mundo
  • 156
  • 11
-2
votes
1 answer

using for,implode and explode function

i need to send emails using implode,explode and for functions this is my code: $ab =implode(",", $dataset['mail']); //emails $ac =implode(",", $dataset['html']); //message $emails[]=$ab; $hts[]=$ac; for($i=0;$i
Emilo
  • 35
  • 7
-2
votes
4 answers

converting from array to string, implode didnt work

connect_error) { die("Connection failed:…