HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers110/franciscaansebeweging.nl/app/helpers.php
<?php

/**
 * This function will print the data in a beautiful way
 * The arrays are going to be collapsible with js
 *
 * @param $data
 */
function dde($data, $die = true)
{

    echo '<pre>';
    // capture the output of print_r
    $out = print_r($data, true);

    // replace something like '[element] => <newline> (' with <a href="javascript:toggleDisplay('...');">...</a><div id="..." style="display: none;">
    $out = preg_replace_callback('/([ \t]*)(\[[^\]]+\][ \t]*\=\>[ \t]*[a-z0-9 \t_]+)\n[ \t]*\(/iU', 'callback_replace', $out);
    // replace ')' on its own on a new line (surrounded by whitespace is ok) with '</div>
    $out = preg_replace('/^\s*\)\s*$/m', '</div>', $out);

    // print the javascript function toggleDisplay() and then the transformed output
    echo '<script language="Javascript">function toggleDisplay(id) { document.getElementById(id).style.display = (document.getElementById(id).style.display == "block") ? "none" : "block"; }</script>' . "\n$out";
    echo '</pre>';
    if ($die) {
        die();
    }
}

function htmlizeEmails($text){
    preg_match_all('/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6})/', $text, $potentialEmails, PREG_SET_ORDER);

    $potentialEmailsCount = count($potentialEmails);
    for ($i = 0; $i < $potentialEmailsCount; $i++) {
        if (filter_var($potentialEmails[$i][0], FILTER_VALIDATE_EMAIL)) {
            $text = str_replace($potentialEmails[$i][0], '<a href="mailto:' . $potentialEmails[$i][0] .'">' . $potentialEmails[$i][0] .'</a>', $text);
        }
    }

    return $text;
}

function callback_replace($matches)
{
//    "'\\1<a href=\"javascript:toggleDisplay(\'".($id = substr(md5(rand().'\\0'), 0, 7))."\');\">\\2</a><div id=\"'.\$id.'\" style=\"\">'"
    $id = rand();
    return $matches[1] . '<a href="javascript:toggleDisplay(' . $id . ')">' . $matches[2] . '</a><div id="' . $id . '" style="display:none;">';
}

function helper_underscoreAll($string)
{
    $string = \Str::slug($string);
    return preg_replace('#([\s| |-])#', '_', $string);
}

function helper_space_to_underscore($string)
{
    return preg_replace('#([\s| |-])#', '_', $string);
}

function helper_underscore_to_space($string)
{

    return ucfirst(preg_replace('#(_)#', ' ', $string));
}