php - make string of check box values array and put qoma

971

HTML

<label>Design</label><input type="checkbox" name="chk_name[]" value="design" />
<label class="page_speed_949538343">Website</label><input type="checkbox" name="chk_name[]" value="website" />
<label>Inquire</label><input type="checkbox" name="chk_name[]" value="inquire" />

PHP

<?php
    if(!empty($_POST['chk_name'])) {

    foreach($_POST['chk_name'] as $val) {
        $chk = $val; checkbox.                  
        } 
    }
?>

All i want here that when I get array of this checkbox I get comma seperated values except the comma at the end value.

775

Answer

Solution:

Assuming your inputs are posted in a form (with method POST):

echo implode(",", $_POST['chk_name']);

implode documentation

People are also looking for solutions to the problem: php - Jenkins-Job fails

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.