I have an array with a whole bunch of badges. I have 3 variables that come from the database. I need some idea of how I can calculate the position of my $current variable to the $start and $end variables and then output as an int for a %.
Example:
$data = array(
['a','b','c'],
['d','e']
);
$start = 'b';
$current = 'c';
$end = 'e';
*Some maths equation to return position value?*
The only idea I have is I probably can count somehow how many variables are between $start and $end and somehow subtract the position of $current?
Update
I tried your code but I think I messed up somewhere:
// Progress Bar configurations
$data = array(
array('diamond_V','diamond_IV','diamond_III','diamond_II','diamond_I'),
array('platinum_V','platinum_IV','platinum_III','platinum_II','platinum_I'),
array('gold_V','gold_IV','gold_III','gold_II','gold_I'),
array('silver_V','silver_IV','silver_III','silver_II','silver_I'),
array('bronze_V','bronze_IV','bronze_III','bronze_II','bronze_I')
);
$start = $start_rank;
$current = $current_rank;
$end = $finish_rank;
foreach($data as $key => &$value){
$value = implode(",", $value);
}
$dataimplode = implode(",", $data);
$key = array_search($current, $dataimplode);
var_dump($key);
['a','b','c']is:'dibdib1' => ['a','b','c']? imo, If your array index was text then it would be easier to position at$current.