Skip to content

Instantly share code, notes, and snippets.

@kodie
Created September 28, 2019 16:04
Show Gist options
  • Save kodie/e7c3b93645b02071c638914ecae5c39a to your computer and use it in GitHub Desktop.
Save kodie/e7c3b93645b02071c638914ecae5c39a to your computer and use it in GitHub Desktop.
Adds double quotes back to a serialized string after they have been removed and then unserializes it to return an array
<?php
$str = unserialize(str_replace('s:0:;', 's:0:"";', preg_replace('/(.*?)(s:\d+:)([^{};]*?)([;}]+)/', '$1$2"$3"$4', $str)));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment