English 中文(简体)
PHP: 2阵列之间的视觉差异
原标题:PHP: visual difference between 2 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 m want is an HTML visual difference between them, like this picture: diff http://imageshack.us/a/img519/3237/diffe.png

这里的任何人都知道有哪三党阶级这样做? 我先看一下他们当中有些人,但没有一人。 =

事先感谢你。

问题回答

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

因此,试图这样做:

当你在浏览器中“print”的东西时,把属性划给肤色,即:

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

php代码只应在服务器方面做一件事:找到不同部分,从而产生相应的类别属性。

现在我没有时间给你写信。

简言之,处决就是这样:

  1. You have php objects on server side
  2. Use php to find difference
  3. Use php to print pure html code
  4. Use css to highlight the coresponding area

我相信,这样做是可能的。 这样做的一个好处是,你会任意控制山角如何像屏幕上一样。

无疑,在服务器方面可以做任何事,即硬性地把所有风格与其他html标签结合起来。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签