Rapide Advanced Adulte
 
 Web|Image|Shop|Video|News|Wmx|Mobile|Wiki|Ajouter ce moteur

     Manuel PHP     
Partager
 
 
Partager
Partager

 

Table :

.xdiff file diff binary
.xdiff file diff
.xdiff file merge3
.xdiff file patch binary
.xdiff file patch
.xdiff string diff binary
.xdiff string diff
.xdiff string merge3
.xdiff string patch binary
.xdiff string patch
 
   

  xdiff_string_patch  


xdiff_string_patch

(PECL)

xdiff_string_patch -- Patche une chaîne avec un diff unifié

Description

string xdiff_string_patch ( string str, string patch [, int flags [, string &error]] )

xdiff_string_patch() patche la chaîne str avec le patch unifié contenu dans la chaîne patch.

flags peut être soit XDIFF_PATCH_NORMAL (mode par défaut, patch normal), soit XDIFF_PATCH_REVERSE (patch inversé).

Si error est fourni, les parties rejetées y sont stockées.

Exemple 1. Exemple avec xdiff_string_patch()

Le code suivant applique les changements à des articles.

<?php
$ancien_article
= file_get_contents('./ancien_article.txt');
$diff = $_SERVER['patch']; /* disons que quelqu'un a passé un patch via un formulaire html */

$errors = '';

$nouvel_article = xdiff_string_patch($ancien_article, $diff, XDIFF_PATCH_NORMAL, $errors);
if (
is_string($nouvel_article)) {
    echo
"Nouvel article:\n";
    echo
$nouvel_article;
}

if (
strlen($errors)) {
    echo
"Rejets : \n";
    echo
$errors;
}

?>

Retourne une chaîne patchée.

Voir aussi xdiff_file_patch().


    Annonces       
 

 Retour au chapitre Php

 

Top
 

Ajouter JungleKey.fr à votre Explorateur

 
 

About Us | © 2007 JungleKey




iBlack | Mobile | Wiki | Ajouter ce moteur
.