[PHP] PERL Caller equivalent function

2006-03-20 Thread sgsweb

Hi,

Perl has a function named caller with the following signature and return 
values:


   ($package, $filename, $line, $subroutine,
$hasargs, $wantarray, $evaltext, $is_require) = caller($i);

This function returns information pertaining to the calling routine, 
such as the name of the function and package that called this function.  
Is there such a function for PHP?


Please let me know.

thanks,
sgs.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is there a way to get multiple values for a singleinput in a form submission?

2006-03-23 Thread sgsweb

Hi Mark,

Actually you can access this variable within Javascript in the following 
manner:



function chgablacted() {
 box = regs['myselect[]'];
 value = box.options[box.selectedIndex].value;
 if (value == 'some value') {
   ...
 } else {
   ...
 }
}

The name of the variable will include the brackets [].

sunil.

mslemko wrote:

Thanks Warren,

This works!

The side effect that is -somewhat- undesirable is that it becomes 
incompatible accessing the field with Javascript. Perhaps there is a 
way to get around that problem though.


-Mark

Warren Vail wrote:

Set the name of your field in html to be;

name="myselect[]"

that way when the form is returned to you each selected value is 
returned to you, for example if you code


$choices = $_POST["myselect"];

choices will be an array containing the actual values selected when 
the form is submitted.


hope this is what you were looking for.

Warren Vail



- clip -



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] int to string

2006-04-06 Thread sgsweb

Hi Tanner,

Here's a completely working piece of code that I got from my hosting 
company.  This looks like it does exactly what you want to do.  I am 
also including the output in the bottom of this e-mail.


sunil.
 output: one thousand one
 ** Written By: Websulting (www dot websulting dot com)
 ** Copyright: You are free to use this script as you like.  This
 **script come with absolutely no guarantee.  You must leave
 **this copyright notice with this file.
 **Report bugs to: contact at websulting dot com
 **
 **/
 class num2str {
   var $one_a=array(
   "one","two","three","four","five","six","seven",
   "eight","nine","ten","eleven","twelve","thirteen",
   "fourteen","fifteen","sixteen","seventeen","eighteen","ninteen");
   var $ten_a=array(
   "ten","twenty","thirty","forty","fifty","sixty","seventy",
   "eighty","ninty");
   var $mil_a=array("thousand","million","billion","trillion");

   //*
   //
   // Method: convert
   // Description: Convert the input number to string representation
   //
   //*
   function convert ($num) {
 $triplets = preg_split('/,/',$num,-1,PREG_SPLIT_NO_EMPTY);
 $length = count($triplets);
 $plc_a= array();
 for ($i=0;$i<$length;$i++) {$plc_a[$i]=$this->tonum($triplets[$i]);}
 $rval = "";
 foreach ($plc_a as $k) {
   if ($k == "") {$length--;continue;}
   $rval .= "$k ". $this->getplace($length--). " ";
 }
 return $rval;
   }

   //*
   //
   // Method: getplace
   // Description: Get the place of the digits.
   //
   //*
   function getplace($i) {
 return $this->mil_a[$i-2];
   }

   //*
   //
   // Method: tonum
   // Description: Convert the individual set to text
   //
   //*
   function tonum ($num) {
 $len = strlen($num);
 switch ($len) {
   case 3:
 if (substr($num,1,2) <=19) {
   return $this->one_a[substr($num,0,1)-1].
 (substr($num,0,1)==0 ? "" : " hundred ").
 $this->one_a[substr($num,1,2)-1];
 }
 return $this->one_a[substr($num,0,1)-1] .
 (substr($num,0,1)==0 ? "" : " hundred ").
 $this->ten_a[substr($num,1,1)-1]." ".
 $this->one_a[substr($num,2,1)-1];
   case 2:
 if (substr($num,0,2) <=19) {
   return $this->one_a[substr($num,0,2)-1];
 }
 return $this->ten_a[substr($num,0,1)-1]." ".
 $this->one_a[substr($num,1,1)-1];
   case 1:
 return $this->one_a[substr($num,0,1)-1];
 }
   }
 }
 //End of class num2str

 $obj = new num2str();
 foreach (array("1,121","121","1,000,010,000,321","1,109,019,000,321", 
"100","70","10","15","5") as $num) {

   print "[$num] => " . $obj->convert($num)."\n";
 }
?>

output:

[1,121] => one thousand one hundred twenty one
[121] => one hundred twenty one
[1,000,010,000,321] => one trillion ten million three hundred twenty one
[1,109,019,000,321] => one trillion one hundred nine billion ninteen 
million three hundred twenty one

[100] => one hundred
[70] => seventy
[10] => ten
[15] => fifteen
[5] => five

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] OT - PHP Webhost Dedicated Server

2006-04-11 Thread sgsweb

Suhas wrote:

Hello,

Any suggestions for Dedicated PHP Webhost.

The current service provider is ok but Customer service is
unsatisfactory. Very bad experience.

Thanks for your help in advance,

SP

  

http://www.websulting.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php