vote up 1 vote down star

Hi ,

Using explode i have converted the string into array ,

But the array look like Array ( [0] => root)

But i want i make my array somthing like Array ( [root] => root)

How to make this manner..

Thanks

flag

What do you need this for? – Matti Virkkunen Apr 5 at 9:27

2 Answers

vote up 9 vote down check
$array = explode($separator, $some_string);
$array = array_combine($array, $array);
link|flag
vote up 2 vote down

You could make it an associative array like so:

$exploded = explode (.......);
$exploded_associative = array();

foreach ($exploded as $part) 
 if ($part) 
  $exploded_associative[$part] = $part;

print_r($exploded_associative); // Will output "root" => "root" ....

what exactly do you need this for?

link|flag

Your Answer

Get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.