|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Registered User
Iscritto dal: Dec 2005
Messaggi: 232
|
[PHP] Come cancellare e cambiare una stringa???
Ammetto che non sono una cima nel programmare in PHP. Ho un piccolo problema. Devo inserire in una pagina un file HTM. Sembrerebbe tutto semplice...il comando che conosco io è:
Codice PHP:
<html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><center><table cellspacing='0' cellpadding='2' border='1'> (che si ripete più volte nel file datigen.htm) con questa stringa: <html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><table class='marca' border= 1 cellspacing= 0 cellpadding= 2 > Per poi stampare il tutto a video. Qualcuno sa gentilmente aiutarmi??? ![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Iscritto dal: Dec 2002
Messaggi: 3359
|
datigen.htm da dove lo prendi? Cioè come lo crei perchè sinceramente non capisco come fai ad avere un problema simile
![]() Comunque tempo fa ti avevo già mostrato una cosa simile se non sbaglio, lavorando sulle stringhe, prova a ricercare il post, mi sembra che sia grosso modo la stessa cosa! |
![]() |
![]() |
![]() |
#3 |
Senior Member
Iscritto dal: Jan 2006
Città: Pisa
Messaggi: 2498
|
eregi_replace("\n","",$stringa);
Yaoz
__________________
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Iscritto dal: Nov 2003
Messaggi: 980
|
Puoi fare:
Codice:
function callback($buffer) { return (str_replace("<html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><center><table cellspacing='0' cellpadding='2' border='1'>", "<html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><table class='marca' border= 1 cellspacing= 0 cellpadding= 2 >", $buffer)); } ob_start("callback"); include("statistiche/datigen.htm"); ob_end_flush(); Codice:
$filecontent = file_get_contents("statistiche/datigen.htm"); $filecontent = str_replace("<html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><center><table cellspacing='0' cellpadding='2' border='1'>", "<html><head><link href='fantamister.css' rel='stylesheet' type='Text/css'></head><body><table class='marca' border= 1 cellspacing= 0 cellpadding= 2 >", $filecontent )); echo $filecontent; Ultima modifica di kk3z : 08-09-2006 alle 18:54. Motivo: file invece di file_get_contents |
![]() |
![]() |
![]() |
#5 | |
Senior Member
Iscritto dal: Jan 2006
Città: Pisa
Messaggi: 2498
|
Quote:
__________________
![]() |
|
![]() |
![]() |
![]() |
#6 | |
Registered User
Iscritto dal: Dec 2005
Messaggi: 232
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#7 |
Senior Member
Iscritto dal: Nov 2003
Messaggi: 980
|
Il primo esempio l'ho copiato pari pari dalla documentazione php
![]() ![]() ![]() Il secondo esempio con la correzione di Alex prende il contenuto del tuo file, sostituisce quello che si deve sostituire e lo outputta/echoa/printa ![]() ![]() Alex, ora mi spieghi eregi_replace("\n","",$stringa)? Ultima modifica di kk3z : 08-09-2006 alle 19:07. |
![]() |
![]() |
![]() |
#8 | |
Senior Member
Iscritto dal: Jan 2006
Città: Pisa
Messaggi: 2498
|
Quote:
![]()
__________________
![]() |
|
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 07:32.