If you want to select an array in the array to retrieve data from a particular variable and sorted you can use the following as an example:
<?php
$f = array(
array('Name' =>'Ucup',
'Class' => 7),
array('Name' => 'Faizal',
'Class' => 9),
array('Name' => 'Abdul',
'Class' => 8)
);
function sort($r,$d)
{
return strnatcmp($r['Name'],$d['Name']);
}
usort($f,'sort');
foreach($f as $k=>$v)
{
echo $v['Name'];
}
?>
$f = array(
array('Name' =>'Ucup',
'Class' => 7),
array('Name' => 'Faizal',
'Class' => 9),
array('Name' => 'Abdul',
'Class' => 8)
);
function sort($r,$d)
{
return strnatcmp($r['Name'],$d['Name']);
}
usort($f,'sort');
foreach($f as $k=>$v)
{
echo $v['Name'];
}
?>
On the listing coding above are arrays in the array contains variables and class name with a certain value, the first array contains the name of the class ucup and 7, both faizal and 9th grade, third grade 8. The name Abdul
function sequence {return strnatcmp}; // useful to sort the array of characters in the array ($ r $ d);
foreach ($ f as $ k => $ v); // $ f is the name of an array of data and then split $ k and $ v variable.
echo $ v [ 'name']; // display the variable ($ v) the contents of the value of 'name';
The result:
If you have any questions please comment.
Do not forget to like and share.
Learn Programming in fajaryusuf.com wrote. :)
function sequence {return strnatcmp}; // useful to sort the array of characters in the array ($ r $ d);
foreach ($ f as $ k => $ v); // $ f is the name of an array of data and then split $ k and $ v variable.
echo $ v [ 'name']; // display the variable ($ v) the contents of the value of 'name';
The result:
The contents of the variable names will be ordered
If you have any questions please comment.
Do not forget to like and share.
Learn Programming in fajaryusuf.com wrote. :)
Comments