# firebox/1.0.10/Inc/Framework/Inc/Helpers/SearchDropdownBaseHelper.php

FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin &amp; Cart Abandonment, version 1.0.10. 73 lines.

- Page: https://pluginprobe.com/plugins/firebox/1.0.10/code/Inc/Framework/Inc/Helpers/SearchDropdownBaseHelper.php
- Raw: https://pluginprobe.com/plugins/firebox/1.0.10/raw/Inc/Framework/Inc/Helpers/SearchDropdownBaseHelper.php
- Modified: 2022-01-25T15:27:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/firebox/1.0.10/code/Inc/Framework/Inc/Helpers/SearchDropdownBaseHelper.php#L10-L20`.

```php
<?php
/**
 * @package         FirePlugins Framework
 * @version         1.0.21
 * 
 * @author          FirePlugins <info@fireplugins.com>
 * @link            https://www.fireplugins.com
 * @copyright       Copyright © 2022 FirePlugins All Rights Reserved
 * @license         GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
*/

namespace FPFramework\Helpers;

if (!defined('ABSPATH'))
{
	exit; // Exit if accessed directly.
}

class SearchDropdownBaseHelper
{
	/**
	 * Parses given data to a key, value, lang array
	 * 
	 * @param   array  $items
	 * 
	 * @return  array
	 */
	public static function parseData($items)
	{
		$data = [];

		foreach ($items as $key => $value)
		{
			$data[] = [
				'id' => $key,
				'label' => $value,
				'lang' => $key
			];
		}
		
		return $data;
	}
	
	/**
	 * Gets items from the Selected Items IDs
	 * 
	 * @param   array   $needle
	 * @param   array   $haystack
	 * 
	 * @return  array
	 */
    public function getSelectedItems($needle, $haystack)
    {
		$needle = !is_array($needle) ? (array) $needle : $needle;
		
		$parsed = [];

		foreach ($haystack as $key => $value)
		{
			if (!in_array($value['id'], $needle))
			{
				continue;
			}
			
			$parsed[] = [
				'id' => $value['id'],
				'title' => $value['label']
			];
		}
		
		return $parsed;
    }
}
```
