<?php
if (isset($_POST['t']) AND isset($_POST['s'])) {
$t = $_POST['t'];
$s = $_POST['s'];
$v = $s/$t;
echo 'Скорость: '.$v;
}
<form method=POST action="">
<label>Время</label>
<input type="text" name="t">
<label>Расстояние</label>
<input type="text" name="s">
<br>
<input type="submit" value="Отправить">
</form>
header('Content-Encoding: UTF-8');
header('Content-Type: text/csv; charset=utf-8' );
header(sprintf( 'Content-Disposition: attachment; filename=data.csv' ) );
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
$df = fopen( 'php://output', 'w' );
//This line is important:
fputs( $df, "\xEF\xBB\xBF" ); // UTF-8 BOM !!!!!
foreach ( $data as $row ) {
fputcsv( $df, $row , ';');
}
fclose($df);
<?php
$string = 'слово1, слово2 длинноолов1 слово3: слово4. длинноесловоболее20символов';
function getWordsFromString($string)
{
if (preg_match_all("/\b(\w+)\b/ui", $string, $matches)) {
return $matches[1];
}
return $matches;
}
$matches = getWordsFromString($string);
foreach($matches as $key => $m) {
if (mb_strlen($m, 'UTF-8') > 20) {
unset($matches[$key]);
}
}
print_r($matches);
Array ( [0] => слово1 [1] => слово2 [2] => длинноолов1 [3] => слово3 [4] => слово4 )