PHP: visual difference between two arrays

I have these arrays:

<?php

// New
$array1 = array(
    array(
        'g_id' => '1',
        'g_title' => 'Root Admin',
        'g_perm_id' => '1',
        'g_bitoptions' => '0'
    ),
    array(
        'g_id' => '2',
        'g_title' => 'Member',
        'g_perm_id' => '2',
        'g_bitoptions' => '32'
    ),
    array(
        'g_id' => '3',
        'g_title' => 'Banned',
        'g_perm_id' => '3',
        'g_bitoptions' => '0'
    )
);

// Old
$array2 = array(
    array(
        'g_id' => '1',
        'g_title' => 'Admin',
        'g_perm_id' => '1',
        'g_bitoptions' => '0'
    ),
    array(
        'g_id' => '2',
        'g_title' => 'User',
        'g_perm_id' => '2',
        'g_bitoptions' => '0'
    ),
    array(
        'g_id' => '4',
        'g_title' => 'Validating',
        'g_perm_id' => '4',
        'g_bitoptions' => '0'
    )
);

What I want is the visual difference between them, for example, this picture: diff http://imageshack.us/a/img519/3237/diffe.png

Does anyone know any third-party class that does this? I looked at some, but none of them had it. = /

Thanks in advance.

+3
source share
2 answers

this may not be directly related to your question. If you examine the sample image from a link, I am afraid that the selected area is determined by javascript and / or rather by PHP - justification: because you cannot define a simple diff () algorithm to get the selection in this way.

, - :

"" - , ,

<php code>
    <div class="red">blah blah blah</div>
    <div class="green">blah blah blah</div>
</php code>

PHP- : , , .

, , .

, :

  • php .
  • php,
  • php HTML-
  • css .

, . , , .

, , , html

+1

PEAR Text_Diff. http://www.hawkee.com/snippet/2238/

diff var_export ($ array1, TRUE) var_export ($ array2, TRUE), , .

PS. Text_Diff: " , - . pear.horde.org, Horde_Text_Diff."

0

Source: https://habr.com/ru/post/1736586/


All Articles