Find and Replace Strings in Serialized Strings

The problem with serialized inputs is that – so basically the size of the string is remembered:


If you url is shorter / longer then the new size must be updated which makes it difficult for FIND AND REPLACE

Basically you need to unserialize the array then serialize it again if you want to find and replace

I made a tool for that:

And the code if anyone is wondering



            background-color: #444444;
            color: #dddddd;
            font-size: 11px;
            white-space: normal;
            padding: 15px;
            word-break: break-all;

    <form method="post">
    <div class="setting-label">
        <h5>Serialized Data</h5>
        <textarea rows="20" name="serializeddata"><?php
    echo $_POST['serializeddata'];
    <div class="setting-label">
        <input type='text' name="search" value="<?php
            echo $_POST['search'];
    <div class="setting-label">
        <h5>Replace With</h5>
        <input type='text' name="replace" value="<?php
            echo $_POST['replace'];
    <button type="submit">Replace</button>

    $string_data = $_POST['serializeddata'];

    $arr = unserialize($string_data);

    include_once "dzs_functions.php";


//    print_r($arr);
<pre><?php echo htmlentities(serialize($arr)); ?></pre><?php
if (!function_exists('replace_in_matrix')) {

    function replace_in_matrix($arg1, $arg2, &$argarray) {
        foreach ($argarray as &$newi) {
            if (is_array($newi)) {
                foreach ($newi as &$newj) {
                    if (is_array($newj)) {
                        foreach ($newj as &$newk) {
                            if (!is_array($newk)) {
                                $newk = str_replace($arg1, $arg2, $newk);
                    } else {
                        $newj = str_replace($arg1, $arg2, $newj);
            } else {
                $newi = str_replace($arg1, $arg2, $newi);


Leave a comment

Your email address will not be published

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

16 − 15 =

{"type":"main_options","images_arr":"'#ffffff'","enable_ajax":"off","soundcloud_apikey":"","bg_isparallax":"off","bg_slideshow_time":"0","bg_transition":"slidedown","site_url":"http:\/\/","theme_url":"http:\/\/\/wp-content\/themes\/qucreative\/","blur_ammount":"26","width_column":"50","width_section_bg":"","width_gap":"30","border_width":"0","border_color":"#ffffff","translate_leave_a_comment":"Leave a comment","translate_leave_a_comment_to":"Leave a comment to","is_customize_preview":"off","width_blur_margin":"30","gallery_w_thumbs_autoplay_videos":"off","enable_native_scrollbar":"on","content_enviroment_opacity":"30","menu_enviroment_opacity":"70"}