Name | Description |
---|---|
repair | Repair serialized data by correcting invalid length values |
replace | Safely replace all occurrences of a string in serialized data |
Description
public repair (string $input)
Repair serialized data by correcting invalid length values
Parameters
(string) $input
Return values
string
$output = SerializedSearchReplace::repair('a:1:{s:4:"name";s:7:"Test";}');
Returns:
a:1:{s:4:"name";s:4:"Test";}
Description
public replace (string|array $search, string|array $replace, string $subject, int|null &$count)
Safely replace all occurrences of a string in serialized data
Parameters
(string|array) $search
(string|array) $replace
(string) $subject
(int|null) &$count
Return values
string
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