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
3 answers

Explode an longtext into array

I have longtext column in mysql db and want to expldoe it into array. But explode returns me only 1 string. $temp_array_links[] = $item->links; //array value: http://google.com/ http://test.com/ http://test1.com/ $temp_string = implode(" ",…
user3341505
-2
votes
2 answers

php: how can i add an addition for all values of an imploded array

Here is my code: $array=array("x1","x2"); $array=implode(" AND ",$array); echo $array; printing out: x1 AND x2 but i want it automatically print for each values of array to: x1=x1+y AND x2=x2+y
-2
votes
3 answers

Explode the string using the integer location

My input is this: $str = ' 1. Admin, Administrator,3. Visor, Super,4. Team, Super User,5. lastname, employee' how can I have the following output using array Explode? array( [0] => Array ( [0] => 1 [1] => Admin [2] => Administrator) …
Daphnne
  • 116
  • 1
  • 1
  • 12
-2
votes
2 answers

PHP: Implode Comma Separated in min() function

I'm trying to implement the min() function in my PHP code. The min value should be retried like this: $ar=array($data[Price]); echo min($ar); The problem is that when I echo out $data[Price] I get my prices without commas nor spaces, so it becomes…
user2635574
  • 195
  • 2
  • 6
  • 16
-2
votes
2 answers

How to query a database with an array outside a loop

Hie. I am trying not to place an SQL query inside a loop, since this improves performance. I think I am supposed to use implode. But can't figure out how to do it. Here is my code:
-2
votes
2 answers

implode() invalid arguments

When I try to run this code: $arraytest = implode(", ", $array['playerList']); print $arraytest; I'm getting this error: Warning: implode() [function.implode]: Invalid arguments passed in /home/crafter/public_html/index.php It's supposed to…
finst33
  • 141
  • 1
  • 3
  • 11
-2
votes
4 answers

Imploding in PHP

I have an array having various numbers: $array = [1,2,3,4]; I would like to have some code that will extract those values and prepend 'ad' to them while imploding into an html attribute:
How can I do that?
urok93
  • 537
  • 3
  • 7
  • 25
-2
votes
1 answer

check value containing words implode / different array with array intersect

I wanted to check to enter data into the database.Checks are as follows $implode1 = "cat, dog, chicken"; $implode2 = "cow, goat, cat"; If the cat in the variable $implode1 is also contained in the variable $implode2, it should display a warning…
user1798945
  • 145
  • 1
  • 2
  • 7
-3
votes
4 answers

PHP implode function not working

i have an array and i want to convert this array in comma seprated string by implode function but this is not working. my code is below.
Manish Jangir
  • 5,329
  • 4
  • 42
  • 75
-3
votes
3 answers

Move last array string to end of second last array string

I have an array like this: $array = array( 0 => "a,b", 1 => "c,d", 2 => "e,f", 3 => "g,h", ); I would like to merge the last two array elements (2 and 3) into a one like this: $array = array( 0 => "a,b", 1 => "c,d", 2…
Optimus Prime
  • 308
  • 6
  • 22
-3
votes
3 answers

Is there any way to implode the key and values of an associative array in PHP without using a foreach or other function?

I have an associative array like this: $myarray = array('a' => 1, 'b' => 2, 'c' => 3); And I want to show the array keys and values like this: a is 1, b is 2, c is 3 I don't want to do this by using print_r or var_dump. And I don't want to use a…
celalk38
  • 81
  • 8
-3
votes
1 answer

Add array attributes to implode()

I don't know PHP, but I have to work in it. I need add to $attr['ids'] array with $gallery_setting. function the_featured_image_gallery( $atts = array() ) { $gallery_setting = get_theme_mod( 'featured_image_gallery' ); if ( is_array(…
-3
votes
1 answer

selected drop box shows 2 values from mysql database

Hey I am having some trouble with my dropdown menu values that I retrieve from my database. I see two values instead of one. $con = mysqli_connect("localhost","root","") ; $myDB = mysqli_select_db($con, "test"); $dbEnc = mysqli_set_charset($con,…
The ONLY One
  • 37
  • 1
  • 11
-3
votes
1 answer

Implode multi-dimensional array with different delimiters?

I'm looking to implode my array into a string that looks like this: 1,a,v,v|2,b,v,v|3,c,v,v|4,d,v,v|5,d,v,v Here's my array: array (size=5) 0 => array (size=4) 0 => string '1' (length=1) 1 => string 'a' (length=1) 2 =>…
KeepCool
  • 497
  • 1
  • 6
  • 24
-3
votes
2 answers

convert array to string php

I have array like this $test=Array ( [0] => en [1] => fr ) when I use this command $a=implode(",",$test); print_r($a); result is: en,fr but I want this result 'en','fr'
paranoid
  • 6,799
  • 19
  • 49
  • 86
1 2 3
49
50