# Wordpress DB string to array (ok)

[https://stackoverflow.com/questions/33199199/wordpress-db-string-to-array](https://stackoverflow.com/questions/33199199/wordpress-db-string-to-array)

I'm fetching a string from Wordpress DB that look's like this:

&#x20;`a:21:{s:18:"openhours_Sun_text";s:17:"String1";s:19:"openhours_Sun_start";s:4:"9:00";s:17:"openhours_Sun_end";s:5:"22:00"; s:18:"openhours_Mon_text";s:13:"String2";s:19:"openhours_Mon_start";s:4:"9:00";s:17:"openhours_Mon_end";s:5:"22:00"; s:18:"openhours_Tue_text";s:17:"String3";s:19:"openhours_Tue_start";s:4:"9:00";s:17:"openhours_Tue_end";s:5:"22:00"; s:18:"openhours_Wed_text";s:17:"String4";s:19:"openhours_Wed_start";s:4:"9:00";s:17:"openhours_Wed_end";s:5:"22:00"; s:18:"openhours_Thu_text";s:8:"String5";s:19:"openhours_Thu_start";s:4:"9:00";s:17:"openhours_Thu_end";s:5:"22:00"; s:18:"openhours_Fri_text";s:6:"String6";s:19:"openhours_Fri_start";s:4:"9:00";s:17:"openhours_Fri_end";s:5:"16:00"; s:18:"openhours_Sat_text";s:8:"String7";s:19:"openhours_Sat_start";s:5:"19:00";s:17:"openhours_Sat_end";s:5:"23:00";}`

How i can transfer it to array in php?

```
<?php
			global $wpdb;
			$result = $wpdb->get_results ( "SELECT setting_data FROM wp_wpf_filters" );
			$aaa = $result[0]->setting_data;
			echo '<pre>';
				var_export($aaa);
			echo '</pre>';
		?>
```

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MR5ML9baiuB8WZpQuwe%2F-MR5MyPtOTFn8-PKfe8e%2FScreenshot_2.jpg?alt=media\&token=e3728846-f28c-4240-a387-4cd47814a9b1)

&#x20;You can use the `maybe_unserialize` function to convert the data to an array.

![](https://2370029328-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LWPtKFbhw0XehxVuoiZ%2F-MR5ML9baiuB8WZpQuwe%2F-MR5Mnxz4AdMJnl5TbnK%2FScreenshot_1.jpg?alt=media\&token=8f9714f4-b05e-429c-a752-0f3c4f0e8e93)

```
<?php
			global $wpdb;
			$result = $wpdb->get_results ( "SELECT setting_data FROM wp_wpf_filters" );
			$aaa = $result[0]->setting_data;
			$pia = maybe_unserialize( $aaa );
			echo '<pre>';
				var_export($pia);
			echo '</pre>';
		?>
```
