Re: swaping numerical index for keys
| From: | Matt Monaco | Date: | Fri, 25 Nov 2005 22:19:12 +0000 |
| Subject: | Re: swaping numerical index for keys | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-226433@lists.php.net to get a copy of this message | ||
function addAssoc($ary_stat)
{
$ls_statfields = array(.....);
while ($assoc = each($ls_statfields)) {
$ary_stat[$assoc['key']] = $ary_stat[$assoc['value']];
}
return $ary_stat;
}
This should do what you want. I'm not sure if you want to remove the
numeric keys entirely, but after this function they still exist.
Matt
"Pooly" <pooly7@gmail.com> wrote in message
news:8db58d6b0511251326h4fc4ea3fg@mail.gmail.com...
Hi,
I've an array :
$ls_statfields=array(
"rfile" =>0,
"file" =>1,
"dev" =>2,
"ino" =>3,
"mode" =>4,
"nlink" =>5,
"uid" =>6,
"gid" =>7,
"rdev" =>8,
"size" =>9,
"atime" =>10,
"mtime" =>11,
"ctime" =>12,
"blksize" =>13,
"blocks" =>14
);
Which is the correspondance between the numerical and keys for stat
before PHP 4.0.6 :
http://uk.php.net/manual/en/function.stat.php
What would be the fastest solution to transform the result from stat
to the one with the keys (before 4.0.6 :-) ? (i.e. Exchanging
numerical indexing the for hash keys in the ls_statfields ?)
--
Pooly
Webzine Rock : http://www.w-fenec.org/