Différences entre les versions de « ERG::Code-2018-2 »

De {}
Aller à la navigation Aller à la recherche
Ligne 26 : Ligne 26 :
  
 
[[Partition Graphique - Jade Rouanet]]
 
[[Partition Graphique - Jade Rouanet]]
 +
 +
==Scripts démos==
 +
 +
<syntaxhighlight lang="php">
 +
function fixBadUnicodeForJson($str) {
 +
    $str = preg_replace_callback(
 +
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
 +
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")).chr(hexdec("$3")).chr(hexdec("$4")); },
 +
    $str
 +
    );
 +
    $str = preg_replace_callback(
 +
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
 +
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")).chr(hexdec("$3")); },
 +
    $str
 +
    );
 +
    $str = preg_replace_callback(
 +
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
 +
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")); },
 +
    $str
 +
    );
 +
    $str = preg_replace_callback(
 +
    '/\\\\u00([0-9a-f]{2})/',
 +
    function($matches) { return chr(hexdec("$1")); },
 +
    $str
 +
    );
 +
    return $str;
 +
}
 +
 +
function textConverter($str){
 +
    $str =  utf8_decode(fixBadUnicodeForJson($str));
 +
    return $str;
 +
}
 +
 +
 +
 +
 +
 +
 +
    $data = file_get_contents("tiina.json");
 +
    $data_traitee = json_decode($data);
 +
    //echo $data_data_traitee;
 +
    //print_r($data_traitee);
 +
    //echo $data_traitee->participants[0]->name;
 +
 +
 +
    echo $data_traitee->messages[5]->content;
 +
 +
    foreach($data_traitee->messages as $message){
 +
        //echo '<p class="message">'.textConverter($message->content).'</p>';
 +
        //echo "<p class=\"message\">$message->content</p>";
 +
 +
        $test1 = strpos($message->content, 'non');
 +
        $test2 = strpos($message->content, 'pas');
 +
 +
        if($test1 != false && $test2 != false){
 +
            echo '<p class="message">'.textConverter($message->content).'</p>';
 +
        }
 +
 +
    }
 +
 +
 +
?>
 +
</syntaxhighlight>

Version du 14 février 2019 à 08:26

Projets

Typoem - Quentin Lamouroux

programme - Clara Sambot

.IMG

TYPO3000 - Nathan Laurent

Destroy prog. zoeflts

Campix_alice

oram - Simon Bouvier

p(A)Rojet - Anthony Pauwels

Trame92 - Hugo Delpluque

Framing - Jean Cardin

Máquina do tempo - Sofia Erzini

test

Partition Graphique - Jade Rouanet

Scripts démos

function fixBadUnicodeForJson($str) {
    $str = preg_replace_callback(
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")).chr(hexdec("$3")).chr(hexdec("$4")); },
    $str
    );
    $str = preg_replace_callback(
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")).chr(hexdec("$3")); },
    $str
    );
    $str = preg_replace_callback(
    '/\\\\u00([0-9a-f]{2})\\\\u00([0-9a-f]{2})/',
    function($matches) { return chr(hexdec("$1")).chr(hexdec("$2")); },
    $str
    );
    $str = preg_replace_callback(
    '/\\\\u00([0-9a-f]{2})/',
    function($matches) { return chr(hexdec("$1")); },
    $str
    );
    return $str;
}

function textConverter($str){
    $str =  utf8_decode(fixBadUnicodeForJson($str));
    return $str;
}






    $data = file_get_contents("tiina.json");
    $data_traitee = json_decode($data);
    //echo $data_data_traitee;
    //print_r($data_traitee);
    //echo $data_traitee->participants[0]->name;


    echo $data_traitee->messages[5]->content;

    foreach($data_traitee->messages as $message){
        //echo '<p class="message">'.textConverter($message->content).'</p>';
        //echo "<p class=\"message\">$message->content</p>";

        $test1 = strpos($message->content, 'non');
        $test2 = strpos($message->content, 'pas');

        if($test1 != false && $test2 != false){
            echo '<p class="message">'.textConverter($message->content).'</p>';
        }

    }


?>