printrvervanger

Gesponsorde koppelingen

PHP script bestanden

  1. printrvervanger

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php

function print_array($array, $levelsOpen = null, $identifier = 0, $level = 0, &$i = 0)
{

    if (!is_array($array))
    {

        return false;
    }


    $success = false;

    while (!$success)
    {

        if (!defined('PRINT_ARRAY_' . $identifier) || $level)
        {

            $success = true;
            define('PRINT_ARRAY_' . $identifier, true);
        }

        else
        {
            $identifier ++;
        }
    }


    if (!defined('PRINT_ARRAY_USED'))
    {

        echo '<style type="text/css">.arrayOutputBlock{font-family:"Courier New","Courier",monospace;font-size:12px}.arrayOutputChildBlock{padding-left: 35px}.arrayOutputBlock a{color:red;text-decoration:none}.arrayOutputBlock a:hover{text-decoration:underline}</style><script type="text/javascript">function toggleArrayOutputBlock(i){var top=document.getElementById("arrayOutputChildBlockTop"+i);var block=document.getElementById("arrayOutputChildBlock"+i);if(top.style.display=="none"){top.style.display="inline";block.style.display="none";}else{top.style.display="none";block.style.display="block";}return false;}function toggleHighlightArrayOutputBlock(i){var block=document.getElementById("arrayOutputChildBlock"+i);if(block.style.backgroundColor=="rgb(255, 255, 153)"||block.style.backgroundColor=="rgb(255,255,153)"){block.style.backgroundColor="";}else{block.style.backgroundColor="rgb(255, 255, 153)";}}</script>';
        define('PRINT_ARRAY_USED', true);
    }


    if (!$level)
    {

        echo '<div class="arrayOutputBlock"><a href="#" onclick="return toggleArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseover="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseout="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');"><em>Array</em></a> <span id="arrayOutputChildBlockTop' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? '' : ' style="display: none;"') . '>(' . count($array) . ' childs)</span><div class="arrayOutputChildBlock" id="arrayOutputChildBlock' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? ' style="display: none;"' : '') . '>';
        print_array($array, $levelsOpen, $identifier, $level + 1, $i);
        echo '</div></div>';
    }

    else
    {
        foreach ($array as $key => $value)
        {

            if (is_array($value))
            {

                $i ++;
                echo '[' . htmlentities($key, ENT_QUOTES) . '] =&gt; <a href="#" onclick="return toggleArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseover="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseout="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');"><em>Array</em></a> <span id="arrayOutputChildBlockTop' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? '' : ' style="display: none;"') . '>(' . count($value) . ' childs)<br /></span><div class="arrayOutputChildBlock" id="arrayOutputChildBlock' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? ' style="display: none;"' : '') . '>';
                print_array($value, $levelsOpen, $identifier, $level + 1, $i);
                echo '</div>';
            }

            elseif (is_object($value))
            {

                $vars = get_object_vars($value);
                $i ++;
                echo '[' . htmlentities($key, ENT_QUOTES) . '] =&gt; <a href="#" onclick="return toggleArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseover="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');" onmouseout="toggleHighlightArrayOutputBlock(\'' . $identifier . 'z' . $i . '\');"><em>' . htmlentities(get_class($value), ENT_QUOTES) . ' Object</em></a> <span id="arrayOutputChildBlockTop' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? '' : ' style="display: none;"') . '>(' . count($vars) . ' childs)<br /></span><div class="arrayOutputChildBlock" id="arrayOutputChildBlock' . $identifier . 'z' . $i . '"' . (($levelsOpen !== null && $level + 1 > $levelsOpen) ? ' style="display: none;"' : '') . '>';
                print_array($vars, $levelsOpen, $identifier, $level + 1, $i);
                echo '</div>';
            }

            elseif (is_bool($value))
            {

                echo '[' . htmlentities($key, ENT_QUOTES) . '] =&gt; <em>' . (($value) ? 'true' : 'false') . '</em><br />';
            }

            elseif (is_null($value))
            {

                echo '[' . htmlentities($key, ENT_QUOTES) . '] =&gt; <em>null</em><br />';
            }

            else
            {
                echo '[' . htmlentities($key, ENT_QUOTES) . '] =&gt; ' . htmlentities($value, ENT_QUOTES) . '<br />';
            }
        }
    }


    return true;
}


?>


Gebruik:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php

class lol
{
    var
$name = 'lol';
}


$array = array(
    true,
    1,
    1.7,
    'lol',
    array_fill(0, 3, 'lol'),
    new
lol,
    null
);

print_array($array);

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.