Re: RE: function help redirect help
| From: | DvDmanDT | Date: | Mon, 27 Oct 2003 19:43:55 +0000 |
| Subject: | Re: RE: function help redirect help | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167782@lists.php.net to get a copy of this message | ||
> Can you see the problem(s) now? Never underestimate the benefits of
writing
> clean code. :-)
Hehe, you should see my code..
function dp_neg($v1,$v2){
$neg = ((substr((string)$v1,0,1)=="-")||((substr((string)$v2,0,1)=="-")));
$bneg=
((substr((string)$v1,0,1)=="-")&&((substr((string)$v2,0,1)=="-")));
if(!$bneg && $neg){
$tmp=$v1*$v2;
$tmp=(string)$tmp;
$an=str_replace("-","+",$tmp);
}
else{
$an="-".($v1*$v2);
}
return $an;
}
function xyz($f,$s){
$f=s_str($f);
$s=s_str($s);
$t=($f==$s)?$f:s_str($f.$s);
return $t;
}
function s_str($str)
{$l=strlen($str);for($x=0;$x<$l;$x++){$ar[]=$str{$x};}sort($ar);return
implode('',$ar);}
$e_a[0]=gs($e1);$e_a[1]=gs($e2);
$e_a[2]=gs($e3);$e_a[3]=gs($e4);
for($i=0;$i<4;$i++){
$t[$i]=split(":",$e_a[$i]);}
$r[0][0]=dp_neg($t[0][3],$t[2][3]);
$r[0][1]=xyz($t[0][2],$t[2][2]);
$r[1][0]=dp_neg($t[0][3],$t[3][3]);
$r[1][1]=xyz($t[0][2],$t[3][2]);
$r[2][0]=dp_neg($t[1][3],$t[2][3]);
$r[2][1]=xyz($t[1][2],$t[2][2]);
$r[3][0]=dp_neg($t[1][3],$t[3][3]);
$r[3][1]=xyz($t[1][2],$t[3][2]);
for($i=0;$i<4;$i++){
$exp .=
((substr($r[$i][0],0,1)=="-")?$r[$i][0].$r[$i][1]:($r[$i][0].$r[$i][1]))."
";}
No, that probably wont compile as that's only a little part of it, but still
a pretty easy part of it.. :)
--
// DvDmanDT
MSN: dvdmandt¤hotmail.com
Mail: dvdmandt¤telia.com
##########################
Please, if you are using windows, you may be infected by Swen. Please go
here to find out more:
http://us.mcafee.com/virusInfo/default.asp?id=helpCenter&hcName=swen
http://securityresponse.symantec.com/avcenter/venc/data/w32.swen.a@mm.html
##########################