Reply to Re: PHP Array Creation

Your name:

Reply:


Posted by Dave M on 12/29/05 21:23

In article <1135759060.667327.225180@z14g2000cwz.googlegroups.com>, Prince of
Code says...
>
>Hey Guys
>Lets assume we have two arrays
>one bug array - main array
>another user array - sub array
>
>The bug array contains the id of the user to whom the bug is
>assigned to.
>This Id is present in the user array for example
>bug - IE Error has assignedto id as 2
>this id 2 corresponds to user Peter in the user array
>how do i create a third array
>bugUserArray such that
>assigned to id of the bug user array should contain the complete
>detail of particular user
>as follows
>
>-----------------------------------------------------------------
>Bug Array
>Array
>(
> [0] => Array
> (
> [varbugId] => 71
> [varbugProjectId] => 23
> [varbugAssignedToId] => 2
> [varbugTitle] => IE Error
> [varbugDescription] => The application ...
> )
>
> [1] => Array
> (
> [varbugId] => 72
> [varbugProjectId] => 45
> [varbugAssignedToId] => 3
> [varbugTitle] => General Protection fault
> [varbugDescription] => GPF Fault occurs ...
> )
>
> [2] => Array
> (
> [varbugId] => 73
> [varbugProjectId] => 23
> [varbugAssignedToId] => 2
> [varbugTitle] => Login Problem
> [varbugDescription] => User banned by the admin can...
> )
>
>)
>
>-------------------------------------------------------
>user Array
>Array
>(
> [0] => Array
> (
> [varUserId] => 1
> [varUserLoginName] => smith
> [varUserPassword] => password
> [varUserFullName] => Mr Smith
> [varUserEmail] => smith@gmail.com
> [varUserDateCreated] => 2005-12-15 15:17:41
> )
>
> [1] => Array
> (
> [varUserId] => 2
> [varUserLoginName] => Peter
> [varUserPassword] => Peter
> [varUserFullName] => Xavier Peter
> [varUserEmail] => peter@gmail.com
> )
>
> [2] => Array
> (
> [varUserId] => 3
> [varUserLoginName] => coolguy
> [varUserPassword] => password
> [varUserFullName] => Administrator
> [varUserEmail] => coolguy@gmail.com
> )
>
> [3] => Array
> (
> [varUserId] => 4
> [varUserLoginName] => alzemer
> [varUserPassword] => alzemerlogin
> [varUserFullName] => Alzemer Alex
> [varUserEmail] => alzemer@gmail.com
> )
>)
>
>bug user array
>-------------------------------------------------------------------
>Bug User Array
>Array
>(
> [0] => Array
> (
> [varbugId] => 71
> [varbugProjectId] => 23
> [varbugAssignedToId] => Array
> (
> [varUserId] => 2
> [varUserLoginName] => Peter
> [varUserPassword] => Peter
> [varUserFullName] => Xavier Peter
> [varUserEmail] => peter@gmail.com
> )
> [varbugTitle] => IE Error
> [varbugDescription] => The application ...
> )
>
> [1] => Array
> (
> [varbugId] => 72
> [varbugProjectId] => 45
> [varbugAssignedToId] => Array
> (
> [varUserId] => 4
> [varUserLoginName] => alzemer
> [varUserPassword] => alzemerlogin
> [varUserFullName] => Alzemer Alex
> [varUserEmail] => alzemer@gmail.com
> )
> [varbugTitle] => General Protection fault
> [varbugDescription] => GPF Fault occurs ...
> )
>
> [2] => Array
> (
> [varbugId] => 73
> [varbugProjectId] => 23
> [varbugAssignedToId] => Array
> (
> [varUserId] => 3
> [varUserLoginName] => coolguy
> [varUserPassword] => password
> [varUserFullName] => Administrator
> [varUserEmail] => coolguy@gmail.com
> )
> [varbugTitle] => Login Problem
> [varbugDescription] => User banned by the admin can...
> )
>
>)
>

Probably a couple of ways to approach that. Can try building multiple separate
arrays and use a common key that would apply to all of the arrays you need to
pull information from. Maybe using "varbugId" as the key if it is unique enough,
or create an indexed array so everything is in the right order across all the
arrays.

As another option, multidimensional arrays are useful for storing an array into
another array and may be easier to manage.

Dave
--
Newsguy Bandwidth Blowout 12-29-2005
http://newsguy.com/nolimits.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация