[PHP] Need some help with array sorting

2002-09-12 Thread Will Steffen

Ahem *tap* *tap* is this thing on?

Hi everyone, my name is Will and I've been addicted to php for 3 months
and 21 days... *grin*

I'm hitting a bit of a brick wall in a current project - the answer is
probably quite simple, but I'm still newish to php and coding in general
so bear with me:

I have a multidim array which looks something like :

$blocks[0] = array("param1"=>"4","param2"=>"some other param")
$blocks[1] = array("param1"=>"3","param2"=>"some other param")
$blocks[2] = array("param1"=>"6","param2"=>"some other param")

And so forth

Fairly straight forward you say, my problem is that elements can be
inserted into the blocks array in no particular order and I need to sort
at the top level using the values in param1 - so my output should be:

$sorted_blocks[0] = array("param1"=>"3","param2"=>"some other param")
$sorted_blocks[1] = array("param1"=>"4","param2"=>"some other param")
$sorted_blocks[2] = array("param1"=>"6","param2"=>"some other param")

I've had a long hard look at the manual and all those obscure array
manipulation goodies (ksort, multisort, etc) and done some hunting on
phpbuilder and the like, but turned up zip - either I'm not
understanding the array functions properly, or this can't be done, or
there's a nifty trick for doing it which I havent figured out?  

Ideally I'd like to be populating blocks using an sql query so I could
do an order by or some such upfront, but this world is anything but
ideal.

Any1 got 2c for me?


Thanks in advance
Will




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




RE: [PHP] Re: Cry for help

2002-09-12 Thread Will Steffen

Heh - I know how you feel.

I'm an ex network tecchie fighting my way through a career change to web
developer - spent some time messing with various scripting tools and so
forth, but never really had any formal coding experience until I hit php
- if you want some advice on learning php mine is spend the next few
weeks/months just soaking up every tutorial you can lay your hands on -
the best libraries are on phpbuilder, devshed and zend imho - altho
webmonkey also has a couple of really 'beginner' ones (hello world
country) you might want to start out with.

Also one thing no-one ever really tells you about this is that one of
the most important things to learn if you plan on building sites with
php is not php - its html.  I know this is a bit duh!, but seriously -
php is about logical structures - and slapping together a few variables
- it aint that hard once you get in the groove, but if you don't know
your html well enough to handcode it and to deconstruct a fat mess of
tags in your head and visualize what its going to end up looking like on
screen - you're going to have a hard time coding scripts to generate the
stuff.


0.02 - actual mileage may vary - insert coin to generate more bs

Cheers
Will

> -Original Message-
> From: Chad Winger [mailto:[EMAIL PROTECTED]] 
> Sent: 12 September 2002 03:34 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Cry for help
> 
> 
> I have no idea what that means, sorry :)
> 
> My point for wanting to do this isnt because I really want to 
> make a list of the home teams or whatnot. But obviously, at 
> some point, I am going to have to learn how to split 
> different bits of information, how organize them in certain 
> ways, in certain orders etc. So if i can figure out how to 
> get PHP to select the certain bits of info, and then organize 
> them, say, alphabetically, that will teach me how to write 
> some syntax, to use a few different functions and to begin 
> how to set variables.
> 
> in 85 when i had the old Apple IIe I was able to do stuff 
> like this with the if A$=whatever then goto ...  type stuff 
> and it was easy back then. Now i realize PHP is not BASIC, 
> nor am I a little kid anymore, but the basic idea of what i'd 
> like to learn to do is there. So if i can just get used to 
> working with it, then it will come
> 
> -Tree
> 
> Adam Williams <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> te.ms.us...
> > You can use PHP and file() to do with, along with the str 
> functions, 
> > but if I were you and you already know what the filename of 
> the file 
> > is you are working on (or can submit it via a form) I would use the 
> > unix command cut to do the operations on the file.  Use 
> another exec() 
> > or system() and have it run cut -d | -f 4 yourfile.txt and 
> then return 
> > you the output.
> >
> > Adam
> >
> > On Thu, 12 Sep 2002, Chad Winger wrote:
> >
> > > Thanks for the reply :P
> > >
> > > I found it actually. Now I have the apache and php 
> running, and am 
> > > able
> to
> > > run my aforementioned test script locally. I am still looking 
> > > through
> the
> > > manual now for the syntaxes and such. I am also looking 
> on the web 
> > > for
> some
> > > simple prewritten scripts to run and then try to dissect and
> deconstruct.
> > >
> > > With my little test "script" I've written, there are a few things 
> > > I'd
> like
> > > to be able to try to do with it that I think would help 
> my learning
> process
> > > go on more smoothly, but i cant seem to figure out, what 
> functions 
> > > to
> even
> > > begin to try to use.
> > >
> > > I'll give an example.
> > >
> > > This is the result of my little "test" script as printed 
> into a txt
> file.
> > >
> > > |Serie C2 Round 2|09.09.02|20.45|Sangiovannese|Florentia Viola
> > >
> > > So if i fill out the form again, and resubmit, i might 
> get something
> like
> > > this:
> > >
> > > |Serie C2 Round 2|09.09.02|20.45|Sangiovannese|Florentia 
> Viola Serie 
> > > |C2 Round 2|09.09.02|20.45|Gualdo|Florentia Viola
> > >
> > > So for example, lets say I wanted to make another html 
> form that has 
> > > a
> form
> > > field for List team by: and and select either "home" or 
> "away" ... 
> > > by selecting "home", the browser would print out the following:
> > >
> > > Sangiovannese
> > > Gualdo
> > >
> > > so now I need to figure out how to get PHP to do the following:
> > >
> > > #1 look at each line in the text file and treat it 
> individually #2 
> > > select the data after the 4th | from each line #3 print 
> it back to 
> > > the browser
> > >
> > > It's simple things like this that will get me going. I 
> know for guys
> like
> > > you, it would take about 3 minutes to type that up but to me its a
> little
> > > tough trying to figure out how and where to use what. This manual 
> > > isnt
> the
> > > most well put together in my opinion, its tough to locate 
> things. So 
> > > if someone or something would say to me"well for that 
> operation, 

RE: [PHP] Re: Cry for help

2002-09-12 Thread Will Steffen

Heh good so you're not a complete n00b then :P  Luckily I had a fairly
decent grounding in html and css as well when I got going - I'm just
putting the finishing touches on my first serious project atm using OO
style php which made the learning curve about 10 times steeper as I had
no previous experience with an OO language and the OO tuts as you will
find are pretty thin on the ground and of varying quality - thinking of
writing a few myself when I get a breather :-)

GL and happy reading :-)

Cheers
Will

> -Original Message-
> From: Chad Winger [mailto:[EMAIL PROTECTED]] 
> Sent: 12 September 2002 04:00 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Cry for help
> 
> 
> Html is something i do in my sleep :P thankfully I've been 
> good enough with it to make a decent living with it. What you 
> mention is quite logical, as i would find myself correcting 
> the ppl coding the databases and/or scripts by saying, stuff 
> like "you realize that when the info is returned like that 
> you are going to need four colums in the html, not 3..." and 
> they'd be like, geez..your right...and then they'd have to go 
> back and code again...
> 
> So i am hoping that the html part that i know helps me gets 
> me thru the scripting phase a little easier, although the 
> languages are apples and oranges
> 
> iom looking thru the tuts now :P
> 
> cheers
> 
> -Tree


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




RE: [PHP] Need some help with array sorting

2002-09-13 Thread Will Steffen

Thanks Timo

I figured if it was do-able it would be something like uasort, or uksort
or one of those, but my geek muscles arent quite up to that sort of flex
yet - any one mind giving me some clues as to how to get started using
these functions  - the manual gets pretty vague in this area?


Thanks
Will

> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
> Sent: 13 September 2002 08:41 AM
> To: [EMAIL PROTECTED]
> Cc: timo stamm; Will Steffen
> Subject: Re: [PHP] Need some help with array sorting
> 
> 
> Hi Will,
> 
> 
> You need a customized sort. Have a look at uasort().
> 
> 
> Timo
> 
> 
> Am Donnerstag den, 12. September 2002, um 13:32, schrieb Will Steffen:
> 
> > Ahem *tap* *tap* is this thing on?
> >
> > Hi everyone, my name is Will and I've been addicted to php for 3 
> > months and 21 days... *grin*
> >
> > I'm hitting a bit of a brick wall in a current project - 
> the answer is 
> > probably quite simple, but I'm still newish to php and coding in 
> > general so bear with me:
> >
> > I have a multidim array which looks something like :
> >
> > $blocks[0] = array("param1"=>"4","param2"=>"some other param") 
> > $blocks[1] = array("param1"=>"3","param2"=>"some other param") 
> > $blocks[2] = array("param1"=>"6","param2"=>"some other param")
> >
> > And so forth
> >
> > Fairly straight forward you say, my problem is that elements can be 
> > inserted into the blocks array in no particular order and I need to 
> > sort at the top level using the values in param1 - so my 
> output should 
> > be:
> >
> > $sorted_blocks[0] = array("param1"=>"3","param2"=>"some 
> other param") 
> > $sorted_blocks[1] = array("param1"=>"4","param2"=>"some 
> other param") 
> > $sorted_blocks[2] = array("param1"=>"6","param2"=>"some 
> other param")
> >
> > I've had a long hard look at the manual and all those obscure array 
> > manipulation goodies (ksort, multisort, etc) and done some 
> hunting on 
> > phpbuilder and the like, but turned up zip - either I'm not 
> > understanding the array functions properly, or this can't 
> be done, or 
> > there's a nifty trick for doing it which I havent figured out?
> >
> > Ideally I'd like to be populating blocks using an sql query 
> so I could 
> > do an order by or some such upfront, but this world is anything but 
> > ideal.
> >
> > Any1 got 2c for me?
> >
> >
> > Thanks in advance
> > Will
> >
> >
> >
> >
> > --
> > 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




RE: [PHP] a href...

2002-09-13 Thread Will Steffen

Use &

a href="bug_detail_user.php?id=$id&reporter_id=$reporter_id"

Some reading around post methods and passing data between scripts might
be in order to familarize yourself with all the syntax etc.

Hope this helps

--Will

> -Original Message-
> From: Meltem Demirkus [mailto:[EMAIL PROTECTED]] 
> Sent: 13 September 2002 02:57 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] a href...
> 
> 
> Hi,
> Iwant to send 2 variable by using a href like that:
> 
> a href="bug_detail_user.php?id=$id?reporter_id=$reporter_id"
> 
> 
> isnt this possible because it is taking the data id  as 
> $id?reporter_id=$reporter_id...
> 
> can anyone tell me how I can manage this..
> thanks..
> 
> meltem
> 
> 
> -- 
> 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




RE: [PHP] can you get the name of an object from within it's own class?

2002-09-17 Thread Will Steffen

Hehe why break your brain- give the class an id property - then you can
have a getid method and do something like this

$id = $this->getid();
$this->fpLog = fopen("$id.log","w+");

get_object_vars only seems to return properties so its not gonna help
you.

I'm currently working on an object thang as well and what ive done where
I have whole bunch of similar objects is to chuck them into a name=value
array as they get created so I can find them and fiddle with them again.
I have no idea if that helps you, or if its even good coding practice
(formal training - wots that?)

hey im also a n00b so don't take my word on it  - actual mileage may
vary :-P


Cheers
Will

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED]] 
> Sent: 17 September 2002 11:49 AM
> To: PHP
> Subject: Re: [PHP] can you get the name of an object from 
> within it's own class?
> 
> 
> It's not possible, imagine
> 
> $firstname = new flashPash();
> $secondname = $firstname;
> 
> Now is the log name secondname.log or firstname.log. Use new property.
> 
> Simon McKenna wrote:
> 
> >Hi all,
> >
> >I'm new to the php world and have just finished building my first 
> >class,
> >
> >It works pretty well, but i've run into a quandary adding 
> debug code, 
> >my problem is thus:
> >
> >Many objects get created by this class, often in the same 
> php script, 
> >and the debug log is an actual file.  At the moment i'm 
> naming the file 
> >after the name of the class, but what I would really like to 
> do is name 
> >the log file after the name of the object instantiated from 
> the class. 
> >e.g.
> >
> >class flashPash {
> >
> >   $this->fpLog = fopen("flashPash.log","w+");
> >
> > function debugLog($LogMsg) {
> >  if (($this->debug == true) && (!empty($this->fpLog)))
> >   fwrite($this->fpLog,$LogMsg."\n");
> > }
> >}
> >
> >$fpObject = new flashPash();
> >$fpObject->debug = true;
> >
> >
> >
> >so...is there a way I can get the variable name "fpObject" 
> from within 
> >flashPash itself?  i.e. so I can make the logfile "fpObject.log" 
> >instead of "flashPash.log"
> >
> > I realise it would be trivial to create a new property of 
> the class to 
> >store the debug log filename, but i'm hoping I can avoid this?
> >
> >"get_object_vars" & "get_class" appear to be heading in the right 
> >direction...but not quite...so...any ideas?  is this 
> actually possible? 
> >I kinda want to go down the hierarchical tree, instead of 
> going up it 
> >:)
> >
> >thanks for any help.   php rocks!
> >si
> >
> >
> >
> >
> >  
> >
> 
> 
> -- 
> 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