Categoria: php


Sito web: http://www.hongkiat.com/blog/...-count-in-text/

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
19
07

Autochiudere i tag aperti con php

posted di Administrator, in php, tutorials. No Commenti

function autochiudi_tag($tag,$stringa,$offset=0)
{
if ($offset {
$pos=strpos($stringa,"<$tag",$offset); //posizione carattere di apertura del tag (<)
if ($pos===false) return $stringa;
$temp=substr($stringa,$pos); //stringa dal carattere di apertura del tag in poi
$pos2=strpos($temp,">"); //posizione carattere di fine tag (>) ,sulla stringa dal < in poi

if ($temp{($pos2-1)}!="/")
{

$stringa_prima=substr($stringa,0,$pos);
$stringa_centrale=substr($temp,0,$pos2)." />"; //si sovrascrive ">" con l'auto-chiusura "/ >"
$stringa_dopo=substr($stringa,$pos+$pos2+1);
return autochiudi_tag($tag,$stringa_prima.$stringa_centrale.$stringa_dopo,++$pos);

}
else return autochiudi_tag($tag,$stringa,++$pos);
}else return $stringa;

}

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati

Ottima raccolta di tutorials su good-tutorials.com divisi per categorie.

Sito web: http://www.good-tutorials.com/

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
 
$var = isset($_POST['var']) ? $_POST['var'] : '' ;
 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
 
$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Documents->Open($filename);
$new_filename = substr($filename,0,-4) . ".txt";
// the '2' parameter specifies saving in txt format
$word->Documents[1]->SaveAs($new_filename,2);
$word->Documents[1]->Close(false);
$word->Quit();
$word->Release();
$word = NULL;
unset($word); 
 
$fh = fopen($new_filename, 'r');
// this is where we exit Hell
$contents = fread($fh, filesize($new_filename));
fclose($fh);
unlink($new_filename);
 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
08
07

Decomprimere file zip con php

posted di Administrator, in php, tutorials. No Commenti

In questo articolo vedremo come decomprimere un file zip con php e la libreria pclzip.lib.php.

La libreria
La libreria che ci permette di decomprimere il file si può scaricare dal sito web ufficiale: http://www.phpconcept.net/pclzip/index.en.php. E' opensource e molto facile da usare

Il file php

<form action="index.php?oper=new" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="2000000"/>
Scegli un file zip tuo pc: <input type="file" name="nome"/>
<input type="submit" value="upload"/>
</form>

<?
if($_GET['oper']=="new"){

$uploaddir = "files/";
$uploadfile = $uploaddir . $_FILES['nome']['name'];
$nomez=$_FILES['nome']['name'];
$nomez=str_replace(".zip","",$nomez);

if (move_uploaded_file($_FILES['nome']['tmp_name'], $uploadfile)) {
print "File caricato";
} else {
print "Errore caricamento";
}

include('pclzip.lib.php');
$archive = new PclZip("$uploadfile");
if ($archive->extract(PCLZIP_OPT_PATH, "files/$nomez",PCLZIP_OPT_REMOVE_PATH, '') == 0) {
//die("Error : ".$archive->errorInfo(true));
echo "ERRORE DECOMPRESSIONE";
}
}
?>

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
 
function wordCount($string){
     $words = "";
     $string = eregi_replace(" +", " ", $string);
     $array = explode(" ", $string);
     for($i=0;$i < count($array);$i++) {
         if (eregi("[0-9A-Za-zÀ-ÖØ-öø-ÿ]", $array[$i])) $words[$i] = $array[$i];
  }
     return $words;
 }
 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
 
< ?php
// this must be done somehow how you want
$filename = 'test.txt';
 
$handle = fopen("http://www.foo.com/", "rb");
if($handle){
  $somecontent = stream_get_contents($handle);
  fclose($handle);
 
  $handle = fopen($filename, 'wb');
  if($handle){
    if (fwrite($handle, $somecontent) === FALSE) {
       echo "Cannot write to file ($filename)";
       exit;
    }
    echo "Success, wrote ($somecontent) to file ($filename)";
    fclose($handle);
  }else{
     echo "Cannot create file ($filename)";
     exit;
  }
}
?>
 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati
 
if(eregi("\.(jpg|gif)$", $entry)){   
 
}
 
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments
  • del.icio.us
  • De.lirio.us
  • digg
  • Fark
  • feedmelinks
  • Furl
  • LinkaGoGo
  • Ma.gnolia
  • NewsVine
  • Reddit
  • scuttle
  • Smarking
  • Spurl
  • YahooMyWeb
  • DZone
  • Internetmedia
  • Snap2r
  • Technorati

Ottimo tutorial di carlo daniele su come accedere alle API di flickr con Php

Parte 1: http://digitaladoptive.wordpress.com/...prima-parte/
Parte 2: http://digitaladoptive.wordpress.com/...seconda-parte/
Parte 3: http://digitaladoptive.wordpress.com/...terza-parte/

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • blogmarks
  • co.mments