-2

//for below array i need the values of name to be semi-colon separated output should be monica;pradnesh

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [name] => Monica
                    [address] => Surat
                    [mobile_number] => 8956231245
                    [telephone_number] => 
                    [email_id] => monica@kritva.com
                    [DOB] => 0000-00-00
                    [gender] => female
                    [PAN_number] => ASDFG4567A
                    [customer_type] => SALES
                    [dependency_type] => Retail
                    [cust_id] => 9055954
                    [state] => Gujarat
                    [city] => Surat
                    [zipcode] => 752852
                    [exist_from] => 2016-12-20
                    [edit_date] => 0000-00-00
                    [staff_id] => 
                    [BA_id] => 
                    [id] => 31
                    [nationality] => Indian
                )

    )

[1] => Array
    (
        [0] => Array
            (
                [name] => Pradnesh
                [address] => Surat
                [mobile_number] => 8956231245
                [telephone_number] => 
                [email_id] => pradnesh.valapkar@kritva.com
                [DOB] => 0000-00-00
                [gender] => male
                [PAN_number] => GHJKL9876S
                [customer_type] => NRI
                [dependency_type] => BA
                [cust_id] => 2736738
                [state] => Gujarat
                [city] => Surat
                [zipcode] => 895623
                [exist_from] => 2016-12-21
                [edit_date] => 0000-00-00
                [staff_id] => 
                [BA_id] => 5822043
                [id] => 33
                [nationality] => Indian
            )

    )

)
Pupil
  • 23,834
  • 6
  • 44
  • 66
Shubhangi
  • 69
  • 3

2 Answers2

1

first extract all the name to array $names, then use implode like this:

$names = array_map(function($v){return $v[0]['name'];}, $array);
implode(',', $names);
LF00
  • 27,015
  • 29
  • 156
  • 295
1

Might be this can show you direction.

<?php 
$data = array(
    array(
        array(
          'name' => 'Monica',
          'address' => 'surat'
        ),
        array(
          'name' => 'Priya',
          'address' => 'surat'
        )
    ),
    array(
        array(
          'name' => 'Pradnesh',
          'address' => 'surat'
        ),
        array(
          'name' => 'test',
          'address' => 'surat'
        )
    )
);

array_map(function ($entry) {
    echo implode(';',array_map(function ($d) {
       return $d['name'];
    }, $entry));
}, $data);
?>

Output

Monica;PriyaPradnesh;test
TIGER
  • 2,864
  • 5
  • 35
  • 45