I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component public class AllViewComponent : ViewComponent { private readonly UserManager<ApplicationUser> _userManager; public AllViewComponent(UserManager<ApplicationUser> userManager) { _userManager = userManager; } public async Task<IViewComponentResult> InvokeAsync() { List<StudentViewModel> allUsers = new List<StudentViewModel>(); var items = await _userManager.Users.ToListAsync(); foreach (var item in items) { allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email }); }
Types of array: - In real world we have two types of array. These are following :-
Single dimensional array: -
In this array data items stored in only in one dimension.
Like $word [1] =”hello” which means the array $word stores the items in one dimension such as $word [1] $word [2] $word [3] $word [5] etc. The arrays which we have discussed in previous topics all are single dimensional array.
Multidimensional Arrays: -
If an array is able to store the items at more than one dimensional is called multidimensional array. Multidimensional array comes in picture where we need to store different association with single variable. For example if we want to make a matrix of size 2x2 the array representation will be.
$mat[ 0] [0]=2
$mat[ 0] [1]=4
$mat[ 1] [0]=7
$mat[ 1] [1]=6
Here the array $mat use two direction first is for row and second for column. So this is called two dimensional array. We can create any dimensional array in PHP . Such that
$threeDarray[ ][ ][ ]
$fourDarray[ ][ ][ ][ ]
$fifthDarray[ ][ ][ ][ ][ ]
$nDarray [ ][ ][ ][ ][ ][ ][ ]……..[ ][ ]
Concept of multidimensional array can be understood with the help of example:-
$shop= array(‘fruit’ =>
array(‘red’ => ‘apple’,
‘orange’ => ‘orange’,
‘yellow’ => ‘banana’,
‘green’ => ‘pear’),
‘flower’ =>
array(‘red’ => ‘rose’,
‘yellow’ => ‘sunflower’,
‘purple’ => ‘iris’));
It is simply an array with two values stored in association with keys. Each of these values is
an array itself. After we have made the array, we can reference it like this:-
if we want to check which fruit of color red then we use
$shop [fruit][red]; this statement return the value “apple”.
Comments
Post a Comment