thecodedeveloper.com
thecodedeveloper.com

Reputation: 3240

Show array without index key

print_r($arraydata);

I got output

Array ( [0] => vikas [1] => shirt [2] => cloth1 [3] => test [4] => shirt [5] => cloth2 [6] => avi )

i need to show array like that

$arr = array("vikas","shirt","cloth1","test","shirt","cloth2","avi");

Upvotes: 10

Views: 26793

Answers (2)

mogelbrod
mogelbrod

Reputation: 2316

If comma separation is necessary:

echo '$arr = array(';
foreach ($array as $key => $value) {
  if ($key > 0) echo ',';
  echo '"'.$value.'"';
}
echo ');';

Upvotes: 0

PoulsQ
PoulsQ

Reputation: 2016

Use this :

echo '$arr = array("'.implode('", "', $arraydata).'");';

Upvotes: 16

Related Questions