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

how to properly use implode() with associative arrays

i have a question regarding the implode() in php, i have this array() $user_data = array( 'user_id_num' => $_POST['userid'], 'fullname' => $_POST['userfname'], 'username' => $_POST['useruname'], 'password' => $password_hash ); what…
Pengun
  • 734
  • 1
  • 7
  • 18
3
votes
5 answers

PHP implode explode first and last array value

i'm still a freshman on PHP. So i have a variable called 'full name' and i was trying to explode and implode the first and the last variable value. $fullname='Andre Filipe da Costa Ferreira'; $namepieces=explode('', $fullname); $flname=implode('',…
André Ferreira
  • 185
  • 1
  • 3
  • 16
3
votes
5 answers

PHP implode with increment value

Is there any way to add an increment value while imploding an array? This is the piece of code I'd like to have the increment value: $entries = '
  • ' . implode('
  • ',…
otinanai
  • 3,987
  • 3
  • 25
  • 43
3
votes
2 answers

php implode internationalization

I'm trying to implode an array of values that are wrapped in a i18n function as shown here: I'm getting the following error message: Warning: Illegal offset type in isset or empty…
aurrutia
  • 77
  • 1
  • 7
3
votes
1 answer

Issue exploding a string array when using PDO

The issue is when I execute a var_dump() I receive the desired result, but when PDO handles it skips over one of the array entries it seems as I am not receive the desired result. $bd = $userObj->fetchPanel(array('category_id'=>$cdata['id'])); …
Claude Grecea
  • 543
  • 1
  • 9
  • 19
3
votes
1 answer

php multidimensional array, implode twice?

I need some help trying to implode my multidimensional array twice. I'm using Joomla 2.5 and it's for a backend component.. Here's what the array is: Array ( [jform] => Array ( [options] => Array ( …
SoulieBaby
  • 5,405
  • 25
  • 95
  • 145
3
votes
2 answers

Run a query based on another query using mysql php

The code below searches my mysql database and comes back with postcodes like IG6,RM11,RM8,RM4,RM2,RM6,RM7,RM1,RM5 and a distance using a stored procedure. (All ok) PROBLEM: With these results, I want to search another table in same database that may…
Mikeys4u
  • 1,494
  • 18
  • 26
3
votes
1 answer

Splitting imploded array from mysql to variables in php

Ok basically I can't figure out how to get the imploded result from mysql back to a usable variable in php. The array is throwing me for a loop, and driving me nuts. The checkboxes that are being dynamically created from the db:
BeKustom
  • 47
  • 2
  • 10
2
votes
5 answers

Transpose 2d array, join second level with commas, and join first level with pipes

I have the following two-dimensional array: 01 03 02 15 05 04 06 10 07 09 08 11 12 14 13 16 I want to convert columns to rows then reduce the matrix to a string like the following: 01,05,07,12|03,04,09,14|02,06,08,13|15,10,11,16
smith
  • 5,341
  • 8
  • 31
  • 38
2
votes
2 answers

Error: Object of class stdClass could not be converted to string -- implode() -- php

can anybody help me understand why I get the followint error: Object of class stdClass could not be converted to string in... (the error is pointing to the line with implode(), see below) when I run the following function? function…
Marina Santini
  • 99
  • 1
  • 3
  • 12
2
votes
1 answer

call function on imploded value?

I have an array of values, the values are all in lower case, I want to call ucfirst() on the values. I could do function uc_implode($values){ foreach($values as &$v) $v = ucfirst($v); return $values; } echo implode(', ',…
Hailwood
  • 89,623
  • 107
  • 270
  • 423
2
votes
1 answer

How to get every words before () in a string

How can i get every words before the word inside a () $str = "There are some (Cat) which are wild"; $str = "Animal (Cat) is a domestic pet"; echo implode(" ", array_slice(explode(" ", $str), 0, 2)); I want output as 'There are some (Cat)' and also…
Abigail
  • 63
  • 5
2
votes
4 answers

How to add bullet points to new lines in ACF Text Area field

I have an ACF Text Area field (2 actually) on my clients Wordpress site that will contain a list. The client wants this to output as bullet points on the front end. I am relatively new to JS so trying to work out how exactly to do this! I found this…
Beth
  • 21
  • 3
2
votes
3 answers

How to Split/Explode a string into a numbered lists in PHP?

I am trying to split this string into numbered lists.. str options is "Hello,Howdy,Hola". I need the output to be Hello Howdy Hola This is my code $newstr = 'My values are' . explode(",", $str["options"]) . '
'; However, This causes to only…
2
votes
1 answer

create one in xml with php multiple inputs with same name

I have an XML file in which one child has two categories, but with the same name. I want to add one title to each one. How can we do it in PHP? This is my XML Some Title Name
crazyshark
  • 55
  • 5