[PHP] Email with attachment function

2004-06-17 Thread Mark Cubitt
Hello,

I'm trying to write a function that sends an email with an attachment using
sendmail,
But I can't seem to get it working, the code I currently have is below,
Any ideas would be much appreciated.

I'm probably doing something stupid as the output is what its meant to be
except it isn't divided up (i.e. attachment is text)

Regards

Mark Cubitt



function send_mail($to, $from, $subject, $body, $attachment = '',
$attachmentDir = '')
{

$path_to_sendmail = "/usr/sbin/sendmail";
$fp = popen("$path_to_sendmail -t", "w");

if ($attachment != '')
{

$filename = $attachmentDir.$attachment;

$filePointer = fopen($filename, "rb");

$fileContent = fread($filePointer, filesize($filename));

$fileContent = chunk_split(base64_encode($fileContent));

fclose($filePointer);

$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

$num = fputs($fp, "To: $to\n");
$num += fputs($fp, "From: $from\n");
$num += fputs($fp, "Subject: $subject\n");
$num += fputs($fp, "MIME-Version: 1.0\n");
$num += fputs($fp, "Content-type: multipart/mixed;\n");
$num += fputs($fp, " boundry=\"{".$mime_boundary."}\"\n\n");
$num += fputs($fp, 'This is a multi-part message in MIME
format'."\n");
$num += fputs($fp, "\n");
$num += fputs($fp, "--{".$mime_boundary."}\n");
$num += fputs($fp, "Content-type: text/html;
charset=iso-8859-1\n");
//$num += fputs($fp, "Content-Transfer-Encoding: 7bit\n");
$num += fputs($fp, "\n");
//  $num += fputs($fp, "Subject: $subject\n");
$num += fputs($fp, "$body");
$num += fputs($fp, "--{".$mime_boundary."}\n");
$num += fputs($fp, "--{".$mime_boundary."}\n");
$num += fputs($fp, "Content-type: application/zip;\n");
$num += fputs($fp, " name=\"{".$attachment."}\"\n");
$num += fputs($fp, "Content-Transfer-Encoding: base64\n");
//$num += fputs($fp, "Content-Disposition: attachment;\n");
//$num += fputs($fp, " filename=\"{".$attachment."\"}\n");
$num += fputs($fp, "\n");
$num += fputs($fp, $fileContent);
$num += fputs($fp, "\n");
$num += fputs($fp, "--{".$mime_boundary."}--\n");


}
else
{

$num = fputs($fp, "To: $to\n");
$num += fputs($fp, "From: $from\n");
$num += fputs($fp, "MIME-Version: 1.0\n");
$num += fputs($fp, "Content-type: text/html;
charset=iso-8859-1\n");
$num += fputs($fp, "Subject: $subject\n\n");
$num += fputs($fp, "$body");

}

pclose($fp); if ($num>0) { return 1; } else { return 0; }

} // end function send_mail()



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



RE: [PHP] Whats faster? text files or mysql?

2004-04-20 Thread Mark Cubitt
I'm not sure but I think it would depend on the programming language and
with php File I/O is slower then database (mySql anyway).

Where as Perl would probably be quicker with the text file.

I could be wrong though

Regards

Mark Cubitt

> -Original Message-
> From: Travis Low [mailto:[EMAIL PROTECTED]
> Sent: 20 April 2004 14:12
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Whats faster? text files or mysql?
>
>
> Isn't the database kept in a file?  Why would that file be faster
> than a plain
> text file?
>
> cheers,
>
> Travis
>
> Jay Blanchard wrote:
> > [snip]
> > I have two text files with two rows of data on each line sperated by a
> > tab for about 20 lines in each file. Would it be faster accessing this
> > data by putting it in a mysql table?
> > [/snip]
> >
> > Sounds like the perfect opportunity to set up a test! File I/O is always
> > slower.
> >
>
> --
> Travis Low
> <mailto:[EMAIL PROTECTED]>
> <http://www.dawnstar.com>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] Weird problem with objects

2004-01-23 Thread Mark Cubitt
hi,

I have a shopping cart I'm having probs with.

I have a cart class that starts like this:



require_once("class_database.php"); // Database Class
require_once("class_accessory.php"); // Accessory Class
require_once("class_order.php"); // Order Class

class cart
{

var $database;
var $accessory;
var $order;

function cart() {

$this->$database = new database();
$this->$accessory = new accessory();
$this->$order = new order();

} // end function cart



and has a line like this:



$price = $this->$accessory->get_accessoryPrice("$key");



there is a get_accessoryPrice function in the accessory class,

but it won't work unless I use this line instead:



$price = $this->$$this->$accessory->get_accessoryPrice("$key");



This makes no sense to me what so ever, so can anybody shed some light on it
for me.
I'm prob just making a silly mistake but any help would be very much
appreciated.

Thanks in advance

Regards

Mark Cubitt

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



RE: [PHP] Function returns

2004-01-12 Thread Mark Cubitt


Shawn McKenzie wrote:

> Maybe a dumb question, but as good coding practice, should all functions
> return something even if they don't need to???
>
> Example:
>
> function do_it()
> {
>echo "hi";
> }
>
> --or--
>
> function do_it()
> {
>return echo "hi";
> }
>
> Also, if they do other things but really don't return anything, should
they
> return true maybe???

I don't think there is a right or wrong way but personally I would do it
like this:

function do_it()
{
echo "hi" || return 0;

return 1;
}

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



RE: [PHP] Random Password Making.

2003-03-28 Thread Mark Cubitt
try this

function randpassword () {

$length = 6;

srand((double)microtime()*100);

$string = '';

while(strlen($string) != $length)  {
$type = rand(1,2);

if ($letterammount = 4) {$type = 1;}
if ($numammount = 2) {$type = 2;}

if($type == 1) {
$string = $string . chr(rand(48,57)); // 
numbers
$numammount = ($numammount + 1);
   }
if($type == 2) {
$lettertype = rand(1,2);

  if($lettertype == 1) {$string = $string .
chr(rand(65,90));} // uppercase letters
if($lettertype == 2) {$string = $string . 
chr(rand(97,122));} //
lowercase letters
$letterammount = ($letterammount + 1);
   }
}

return($string);
}

hope that helps

Regards

Mark Cubitt

> -Original Message-
> From: Philip J. Newman [mailto:[EMAIL PROTECTED]
> Sent: 28 March 2003 11:33
> To: [EMAIL PROTECTED]
> Subject: [PHP] Random Password Making.
>
>
> Whats the best way to make a random password with 4 letters and 2 numbers?
>
>
> --
> Philip J. Newman.
> Head Developer
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>
>


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



RE: [PHP] Long script execution and its implications?

2003-03-12 Thread Mark Cubitt
a copy of the code you are using might help for suggestions,

and you say each line has upto 5 seprate querys on your db, are you using
seprate tables to hold that data?

> -Original Message-
> From: Simon Lusted [mailto:[EMAIL PROTECTED]
> Sent: 12 March 2003 14:57
> To: [EMAIL PROTECTED]
> Subject: [PHP] Long script execution and its implications?
>
>
> Hello,
>
> I hope this question isn't too vague.
>
> I am opening a large csv file (up to 30,000 lines), splitting it out into
> its elements and then making several INSERT, SELECT queries on my DB. It's
> a hack and not very elegant (but as a beginner i will try to work on it in
> the coming weeks)
>
> This process is taking a really long time and I get about 5 or 6 thousand
> lines in and php times out (5 minutes).
>
> Now I could set the max_execution_time to a higher level but in
> the back of
> my mind i think there might be a more correct way to make all
> these selects
> and inserts. Like breaking it up into smaller chunks or something.
>
> My question is multifaceted.
>
> a) i can't echo any status information to the screen while the script is
> executing (because of course it hasn't finished yet). But is
> there a way to
> do this (something like line 3..line 4 etc of csv)?
> b) is there a better way (conceptually) to process such a large file with
> each line having up to 5 separate queries on my db.
> c) what would be the implications of raising the memory limit (i
> am running
> apache/php/mysql on windows xp locally on my laptop)
> d) should i just increase max_execution and live with the blank screen for
> 8 minutes (i'm basically trying to crunch data for later reporting)
>
> Any info, direction to documentation welcome (i did look but as a beginner
> I find its hard to know where to start.)
>
> Thanks
> Simon
>
>
>
> For the latest data on the economy and society
> consult National Statistics at http://www.statistics.gov.uk
>
> **
> Please Note:  Incoming and outgoing email messages
> are routinely monitored for compliance with our policy
> on the use of electronic communications
> **
> Legal Disclaimer  :  Any views expressed by
> the sender of this message are not necessarily
> those of the Office for National Statistics
> **
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>
>


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



RE: [PHP] creating flat versions of php pages

2003-02-25 Thread Mark Cubitt
e = "rd";}
else {$cdaytype = "th";}

$commdateser = "$3$cdaytype $commmonth $commyear";

$comment =~ s/\. /\.\r\n/g ;
$comment =~ s/\, /\,\r\n/g ;
$comment =~ s/\! /\!\r\n/g ;
$comment =~ s/\? /\?\r\n/g ;
$comment = "\n".$comment."\n";

if ($auth_name eq '') {$auth_name = 'Anonymous';}

$body = $body.$otbl.''.$ctbl;
$body = $body."$comment$ctbl";
$body = $body."$otbl Submitted by: $auth_nameDate: $commdateser";
$body = $body."$otbl  $ctbl";
}
$sth2->finish;

$desc = "$name, $city, $county, & site title";
$keywords = "$name, $city, $county, & site title";


$htmlCodeNew = $htmlCode;
$htmlCodeNew =~ s/!title!/\r\n$title\r\n/ ;
$htmlCodeNew =~ s/!desc!/\r\n$desc\r\n/ ;
$htmlCodeNew =~ s/!keywords!/\r\n$keywords\r\n/ ;
$htmlCodeNew =~ s/!date!/\r\n$dateser\r\n/ ;
$htmlCodeNew =~ s/!body!/\r\n$body\r\n/ ;

open (FileToWrite, ">$fileName") or die "Can't Create/Open File\r\n";

print FileToWrite "$htmlCodeNew";

close(FileToWrite);

}


$sth->finish;

$dbh->disconnect();


Don't know if that will help at all, and this is just one of the scripts we
use to build some pages.

>
> hi mate i am interested in finding example trawlers in either php
> or perl ,
> is mod_fast_cgi a better way to do this ? is there a way of
> trawling through
> each page creating a html version of it and also converting the links to
> other pages and the other pages too ?
>
> "Mark Cubitt" <[EMAIL PROTECTED]> wrote in message
> news:<[EMAIL PROTECTED]>...
> > Are all the news stories in a database?
> >
> > If so we are current in devolopment of a simaliar site (although not
> news),
> > we are using Perl scripts to build all the HTML pages (both Index's and
> > Pages) during the evening (4am), it takes about 8 secs to build
> 2500 pages
> > and the Perl scripts could be a lot more efficiant, we are
> using PHP todo
> > all the admin and stat areas of the site.
> >
> > Static HTML pages not only increase the speed but they also improve SEO
> > (Search Engine Optimasion) if handled correctly.
> >
> > Don't know if this will help you but maybe it is a an idea.
> >
> > Also i'm sorry if this answer takes this a little off topic.
> >
> > regards
> >
> > Mark Cubitt
> >
> > > -Original Message-
> > > From: electroteque [mailto:[EMAIL PROTECTED]
> > > Sent: 24 February 2003 11:13
> > > To: [EMAIL PROTECTED]
> > > Subject: Re: [PHP] creating flat versions of php pages
> > >
> > >
> > > i dont understand what you mean , anyway, this is a short term
> > > situation as
> > > the site is pretty slow and cpu intensive,  the setup is a sun solaris
> box
> > > running apache 1.3 and php3 , just had a meeting today to push
> > > through apahe
> > > 2 and php 4.3 ut wont happen for a while , we need a solution in the
> next
> > > month, we basically need a system that will trawl the site or
> the latest
> > > news and flatten them so they are less taxing on the server as
> > > our last time
> > > cost us dearly , 170,000 hits in one day !
> > > so would flattening to html solve our problem or is the server
> > > going to get
> > > hammered anyway ?
> > >
> > > "Gonzo" <[EMAIL PROTECTED]> wrote in message
> > > news:[EMAIL PROTECTED]
> > > > > hi guys we have 2 very high traffic sites and we need
> > > > > to be able to make these pages load faster , we are
> > > > > coming up with a solution to make flat file versions of
> > > > > the sites in the short term before we start using
> > > > > caching technologhies is this the right way to go about
> > > > > this ?
> > > >
> > > > I think anyone trying to answer this would need to know
> > > > more about your setup.  Caching is not necessarily the
> > > > answer if a dynamic page is dynamic enough every time to
> > > > be different.  (Please keep this on-list)
> > > >
> > > > > also whats is the best way to parse a php page
> > > > > ie foo.php?id=1, foo.php?id=2 with the contents of each
> > > > > story to a file and update all the links. maybe with
> > > > > naming conventions like foo/1.html, foo/2.html in a mod
> > > > > rewrite style
> > > >
> > > > I like using Variables from URI:
> > > >
> > > >   http://nirvani.org/software/variables_from_uri/
> > > >
> > > > Gonzo
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > >
> > > **
> > > 
> > >  This email has been virus checked by the Eclipse Internet
> > > MAILsafe service
> > > **
> > > 
> > >  www: http://www.eclipse.net.uk/email:
> > > [EMAIL PROTECTED]
> > > **
> > > 
> > >
> > >
> >
>
>
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>
>


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



RE: [PHP] dynamic list box

2003-02-24 Thread Mark Cubitt
don't know if this will help, but you could do something like this

foreach ($hashes as $name => $variable)  {

switch ($name)
{
case 'board':
$nameText = "PCB Type";
break;
case 'size':
$nameText = "PCB Size";
break;
case 'numb':
$nameText = "Amount Required";
break;
case 'days':
$nameText = "Delivery Time";
break;
}


print "$nameText: \n\n";

foreach ($variable as $key => $value)  {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($value == $_POST[$name]) {
print "$key\n";
}
}

}  // end inner for each

foreach ($variable as $key => $value)  {


if  ($value != $_POST[$name]) {
print "$key\n";
}

}  // end inner for each

print "\n\n";

} // end for each  outer

this uses these arrays:

// size options hash
$optionSize = array(
'0.1 Squ.Dcm' => 0.1,
'0.25 Squ.Dcm' => 0.25,
'0.5 Squ.Dcm' => 0.5,
'0.75 Squ.Dcm' => 0.75,
'1 Squ.Dcm' => 1,
'2 Squ.Dcm' => 2,
'3 Squ.Dcm' => 3,
'4 Squ.Dcm' => 4,
'6 Squ.Dcm' => 6,
'8 Squ.Dcm' => 8,
'10 Squ.Dcm' => 10
);



// numb options hash
$optionNumb = array(
'1 circuit' => 1,
'2 circuits' => 2,
'3 circuits' => 3,
'4 circuits' => 4,
'5 circuits' => 5,
'10 circuits' => 10,
'20 circuits' => 20,
'30 circuits' => 30,
'40 circuits' => 40,
'50 circuits' => 50
);



// days options hash
$optionDays = array(
'10 scheduled' => 10,
'5 scheduled' => 6,
'5 working days' => 5,
'4 working days' => 4,
'3 working days' => 3,
'2 working days' => 2,
);


// board options hash
$optionBoard = array(
'0.8 single' => 1,
'0.8 double' => 2,
'0.8 PTH' => 3,
'1.6 single' => 4,
'1.6 double' => 5,
'1.6 PTH' => 6,
        '3.2 single' => 7,
'3.2 double' => 8,
'3.2 PTH' => 9,
// '1.6 4-layer' => 10,
// '1.6 6-layer' => 11,
);

$optionDaysSmall = array('10 scheduled' => 10);


// hashes hash
$hashes = array(
'board' => $optionBoard,
'size' => $optionSize,
'numb' => $optionNumb,
'days' => $optionDays,

);

but it shouldn't be to hard to dynamically make the arrays,

hope this helps

regards

Mark Cubitt

> -Original Message-
> From: Edward Peloke [mailto:[EMAIL PROTECTED]
> Sent: 24 February 2003 14:02
> To: [EMAIL PROTECTED] Php. Net
> Subject: [PHP] dynamic list box
>
>
> Hello,
>
> I have an sql statement that pulls data into a dynamic list box,
> the problem
> is, I have this list box twice on my form, since the query
> returns a lot of
> rows, I do not want to have the query executed twice but I
> populate my list
> box using the while loop so when it is time for the second list box, the
> query is already at end of file.  I tried to get my result then just copy
> that to another array but that doesn't seem to work, any one have
> any ideas?
>
> THanks,
> Eddie
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>
>


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



RE: [PHP] creating flat versions of php pages

2003-02-24 Thread Mark Cubitt
Are all the news stories in a database?

If so we are current in devolopment of a simaliar site (although not news),
we are using Perl scripts to build all the HTML pages (both Index's and
Pages) during the evening (4am), it takes about 8 secs to build 2500 pages
and the Perl scripts could be a lot more efficiant, we are using PHP todo
all the admin and stat areas of the site.

Static HTML pages not only increase the speed but they also improve SEO
(Search Engine Optimasion) if handled correctly.

Don't know if this will help you but maybe it is a an idea.

Also i'm sorry if this answer takes this a little off topic.

regards

Mark Cubitt

> -Original Message-
> From: electroteque [mailto:[EMAIL PROTECTED]
> Sent: 24 February 2003 11:13
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] creating flat versions of php pages
>
>
> i dont understand what you mean , anyway, this is a short term
> situation as
> the site is pretty slow and cpu intensive,  the setup is a sun solaris box
> running apache 1.3 and php3 , just had a meeting today to push
> through apahe
> 2 and php 4.3 ut wont happen for a while , we need a solution in the next
> month, we basically need a system that will trawl the site or the latest
> news and flatten them so they are less taxing on the server as
> our last time
> cost us dearly , 170,000 hits in one day !
> so would flattening to html solve our problem or is the server
> going to get
> hammered anyway ?
>
> "Gonzo" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > > hi guys we have 2 very high traffic sites and we need
> > > to be able to make these pages load faster , we are
> > > coming up with a solution to make flat file versions of
> > > the sites in the short term before we start using
> > > caching technologhies is this the right way to go about
> > > this ?
> >
> > I think anyone trying to answer this would need to know
> > more about your setup.  Caching is not necessarily the
> > answer if a dynamic page is dynamic enough every time to
> > be different.  (Please keep this on-list)
> >
> > > also whats is the best way to parse a php page
> > > ie foo.php?id=1, foo.php?id=2 with the contents of each
> > > story to a file and update all the links. maybe with
> > > naming conventions like foo/1.html, foo/2.html in a mod
> > > rewrite style
> >
> > I like using Variables from URI:
> >
> >   http://nirvani.org/software/variables_from_uri/
> >
> > Gonzo
> >
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>
>


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



RE: [PHP] AUTH (.htaccess style)

2003-02-20 Thread Mark Cubitt
This mail doesn't seem to have gone through first time so here it is again,
sorry if the first mail does eventually turn up.

it will probely need abit of work to be used in your set up, for one i use
postgresql not mysql, but hopefully it will be a start

also if you or anybody else can suggest any improvements please say as they
will be a help

p.s. i'm not a security expert so this is probely not very secure



regards

Mark Cubitt

> -Original Message-
> From: Sebastian [mailto:[EMAIL PROTECTED]]
> Sent: 20 February 2003 09:35
> To: [EMAIL PROTECTED]
> Subject: [PHP] AUTH (.htaccess style)
>
>
> Greetings.
>
> I have a member system which each user has a unique ID, username
> and password.
>
> I want to secure some of my scripts with .htaccess style login,
> Basically I would like to fetch the username and password from
> mysql database, the password is encrypt using md5 hash.
>
> I would like to the ability to include the file into any script I
> would like to protect and validate the user based on the
> information that is stored on the mysql database.
>
> Conclusion: Does anyone know of a handy script that I could use?
>
> Thanks in advanced.
>
> Sebastian - [BBR] Gaming Clan
> http://www.BroadBandReports.com
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>


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




RE: [PHP] AUTH (.htaccess style)

2003-02-20 Thread Mark Cubitt
it will probely need abit of work to be used in your set up, for one i use
postgresql not mysql, but hopefully it will be a start

also if you or anybody else can suggest any improvements please say as they
will be a help

p.s. i'm not a security expert so this is probely not very secure



regards

Mark Cubitt

> -Original Message-
> From: Sebastian [mailto:[EMAIL PROTECTED]]
> Sent: 20 February 2003 09:35
> To: [EMAIL PROTECTED]
> Subject: [PHP] AUTH (.htaccess style)
>
>
> Greetings.
>
> I have a member system which each user has a unique ID, username
> and password.
>
> I want to secure some of my scripts with .htaccess style login,
> Basically I would like to fetch the username and password from
> mysql database, the password is encrypt using md5 hash.
>
> I would like to the ability to include the file into any script I
> would like to protect and validate the user based on the
> information that is stored on the mysql database.
>
> Conclusion: Does anyone know of a handy script that I could use?
>
> Thanks in advanced.
>
> Sebastian - [BBR] Gaming Clan
> http://www.BroadBandReports.com
>
>
> **
> 
>  This email has been virus checked by the Eclipse Internet
> MAILsafe service
> **
> 
>  www: http://www.eclipse.net.uk/email:
> [EMAIL PROTECTED]
> **
> 
>


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




[PHP] Best way to sort a multidimentional array....

2003-02-19 Thread Mark Cubitt
Hello,

I need to manipulate, the following data in a number of diffierent ways 
(specifics follow).
Telephone extension number  -   4 digits in the range 2000-2119
Total time on phone - seconds integer values
Total No. of calls - integer value
Name - A persons name

I'm purposely NOT using a database table for this data.

I'm storing the data in a multidemensional array, the stucture of which 
is below, and I need to sort it by "Total Time On Phone" in decending 
order,  which is the first element of the 'embedded' array. I have got 
an idea of how to write a function to do this, I'm sure I can get it too 
work. But I figured someone must have had to do something like this b4 
and so was after any advice/code and/or a more elegant way of achieving 
what I what?

Any ideas/comments would be well recieved.

Thanks A lot
Best Wishes
Roland Tarver


//just filled with some descriptive default values
$extensionsDetails = array('Total Time On Phone', 'Total Number of 
calls', 'name of person');

// a hash of extention numbers and the $extensionsDetails array (above)
$telData = array(
 // management
 '2000' => $extensionsDetails,
 '2001' => $extensionsDetails,
'2002' => $extensionsDetails,
 '2003' => $extensionsDetails,
 '2004' => $extensionsDetails,
 '2005' => $extensionsDetails,
 
  // sales
  
  '2020' => 
$extensionsDetails,
 '2021' => $extensionsDetails,
 '2022' => $extensionsDetails,
 '2023' => $extensionsDetails,
 '2024' => $extensionsDetails,
 '2025' => $extensionsDetails,
 '2026' => $extensionsDetails,
 '2027' => $extensionsDetails,
 '2028' => $extensionsDetails,
 '2029' => $extensionsDetails,
 '2030' => $extensionsDetails,
 '2031' => $extensionsDetails,
 '2032' => $extensionsDetails,
 '2033' => $extensionsDetails,
 '2034' => $extensionsDetails,
 '2035' => $extensionsDetails,
 '2036' => $extensionsDetails,
 '2037' => $extensionsDetails,
 '2040' => $extensionsDetails,
 '2041' => $extensionsDetails,
 '2043' => $extensionsDetails,
 '2044' => $extensionsDetails,
 '2045' => $extensionsDetails,
 '2046' => $extensionsDetails,
 '2047' => $extensionsDetails,
 '2048' => $extensionsDetails,
 '2049' => $extensionsDetails,
 '2050' => $extensionsDetails,
 '2051' => $extensionsDetails,
 '2052' => $extensionsDetails,
 '2053' => $extensionsDetails,
 '2054' => $extensionsDetails,

  // media/production
  '2101' => $extensionsDetails,
  '2102' => $extensionsDetails,
  '2103' => $extensionsDetails,
  '2104' => $extensionsDetails,
  '2105' => $extensionsDetails,
  '2106' => $extensionsDetails,
  '2107' => $extensionsDetails,
  '2111' => $extensionsDetails,
  '2112' => $extensionsDetails,
 
);   // end TelData array

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