<?
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
case "fr":
//echo "PAGE FR";
include("index_fr.php");//include check session FR
break;
case "it":
//echo "PAGE IT";
include("index_it.php");
break;
case "en":
//echo "PAGE EN";
include("index_en.php");
break;
default:
//echo "PAGE EN - Setting Default";
include("index_en.php");//include EN in all other cases of different lang detection
break;
}
?>
Quantas vezes já precisaram de código em PHP para cortaram uma string a por exemplo 160 caractéres, e sem cortar nenhuma palavra ao meio?
Hoje vou deixar a solução para tirarem só uma parte de uma string sem cortar palavras ao meio.
Conteudo do website em HTML
<body>
<div id="page-wrap">
<!-- all websites HTML here -->
</div>
</body>
Código em CSS para centrar o website
#page-wrap {
width: 800px;
margin: 0 auto;
}
Código para a função
function generateCsv($data, $delimiter = ',', $enclosure = '"') {
$handle = fopen('php://temp', 'r+');
foreach ($data as $line) {
fputcsv($handle, $line, $delimiter, $enclosure);
}
rewind($handle);
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
return $contents;
}
Chamar a Função
$data = array(array(1, 2, 4), array('teste string', 'teste, literal, virgula', 'teste literal "aspas"'), );
echo generateCsv($data);
// output: // 1,2,4 // "teste string","teste, literal, virgula","teste literal""aspas"""
Como fazer um redirect em PHP
<?php header( 'Location: http://www.oseusite.com/pagina.html' ) ; ?>