close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

merge arrays to one string

Thread began 11/05/2009 8:59 am by Steve | Last modified 11/05/2009 1:18 pm by Steve | 1517 views | 3 replies

Steve

merge arrays to one string

Hello,
I have a few repeating regions with checkbox values that I would like to append as one comma separated string.

Individual groups can be posted using the implode function from checkbox arrays []

But trying to merge these to one string is posing a problem.

Here is my code:

$a1 = ((isset($_POST["1pcCB"]))?implode(", ", $_POST["1pcCB"]):""));
$a2 = ((isset($_POST["desksetCB"]))?implode(", ", $_POST["desksetCB"]):"");
$a3 = ((isset($_POST["trimlineCB"]))?implode(", ", $_POST["trimlineCB"]):"");
$a4 = ((isset($_POST["bedRailCB"]))?implode(", ", $_POST["bedRailCB"]):"");
$a5 = ((isset($_POST["specialtyCB"]))?implode(", ", $_POST["specialtyCB"]):"");
$requestedPhones = array_merge($a1, $a2, $a3, $a4, $a5);



Is this not an array: ((isset($_POST["1pcCB"]))?implode(", ", $_POST["1pcCB"]):"")) ?

I'm looking to post $requestedPhones as the final string to be inserted. The individual elements seem to work, such as ((isset($_POST["1pcCB"]))?implode(", ", $_POST["1pcCB"]):"")) properly inserts a comma separated string to the target DB field.
And the array_merge() function works in testing if I use a test array such as :


$my_array1 = array ( 'a', 'b', 'c' );
$my_array2 = array ( 'd', 'e', 'f' );
// append one array to the other
$my_array = array_merge($my_array1, $my_array2);

// print the resulting array to see if it worked
print_r($my_array);

I believe the problem is here:
((isset($_POST["1pcCB"]))?implode(", ", $_POST["1pcCB"]):""))
and that this is not a pure array or some extra syntax is conflicting with the setting of this value to the new var ($a1)...

Anyone see the problem and can offer the solution?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...