Easily replace strings found in content containing data serialized by the serialize function without corrupting your data, by correcting all length values included in these objects before returning the replaced content.
- PHP 4.0.0 or higher
composer require andreekeberg/serialized-search-replace
Basic usage
$output = SerializedSearchReplace::replace(
'http://example.com',
'https://example.com',
serialize([
'url' => 'http://example.com/'
])
);
Returns:
a:1:{s:3:"url";s:20:"https://example.com/";}
Getting the number of replacements performed
Passing $count
by reference to get the total number of replacements performed:
$output = SerializedSearchReplace::replace(
'http://example.com',
'https://example.com',
serialize([
'url' => 'http://example.com/'
]),
$count
);
Value of $count
:
1
Read the contribution guidelines.
Refer to the changelog for a full history of the project.
Serialized Search and Replace is licensed under the MIT license.