phpbar.de logo

Mailinglisten-Archive

[php] String formatieren

[php] String formatieren

Cyrill Schumacher php_(at)_phpcenter.de
Wed, 29 Aug 2001 14:41:36 +0200


> $string mit beliebiger länge soll nach ca 75 Zeichen
> ein <br> erhalten (später mal \n für mail).

da:

function str2br($string,$len,$crlf="\r\n"){

 $sa = preg_split('=\s=',$string);
 $csa = count($sa);
 $ss = '';
 $s2 = array();
 for( $b=0;$b<$csa;$b++ ){

  $s2[$b] = $sa[$b];
  $s2s = implode(' ',$s2);
  if( strlen($s2s) > $len ){
   $s2n = $s2[$b];
   unset($s2[$b]);
   $ss .= implode(' ',$s2).$crlf;
   $s2 = array($s2n);
  }
 }

 return $ss.implode(' ',$s2).$crlf;

}



define('ODBC_BOTH','0');
define('ODBC_ASSOC','1');
define('ODBC_NUM','2');

function odbc_fetch_array(&$result_id,$assoc_num='0'){
 $data = array();

 $cols = odbc_num_fields($result_id);
 for( $c=1; $c <= $cols;$c++ ){

  $field_name = odbc_field_name($result_id,$c);
  $field_data = odbc_result($result_id,$field_name);
  if( $assoc_num == '2' || $assoc_num == '0' ){
   $data[$c] = $field_data;
  }
  if( $assoc_num == '1' || $assoc_num == '0' ){
   $data[$field_name] = $field_data;
  }
 }
 return $data;
}

kiri
________________
8307 305 165 1781




php::bar PHP Wiki   -   Listenarchive