I want to sort the second array($array2) based on first array($field['choices'])
$field_name = "field_52f8fcdd21cb6";
$field = get_field_object($field_name);
foreach( $field['choices'] as $k=>$v) {
echo $k."==".$v."<br>";
}
The above code gives me the following output
Gyana Yagna==Gyana Yagna
Festival==Festival
Retreat==Retreat
Performance==Performance
Swaranjali==Swaranjali
Now the second array starts
echo "<br><br><br>";
$array2 = array("Gyana Yagna","Gyana Yagna","Gyana Yagna","Retreat","Festival","Festival");
foreach( $array2 as $k=>$v)
{
if(in_array($v,$field['choices']))
{
echo $array2[$k]."<br>";
}
else
{
echo $array2[$k+1]."<br>";
}
}
Desired output should be
Gyana Yagna
Gyana Yagna
Gyana Yagna
Festival
Festival
Retreat
Whereas I am getting the following output
Gyana Yagna
Gyana Yagna
Gyana Yagna
Retreat
Festival
Festival
Any help is highly appreciated. Thanks in advance.