| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
Comments:
<***yKen> How do you populate an array within a while statement? <raar> I don't want to run the function again, but do want to know the output to be parsed in the default: case <AzMoo> raar, put the result into a variable first, then call the switch. <raar> okay - I thought there might be a better way to do it, but I'll go your way - thanks :) <freeone3000> AzMoo: Well... thanks... That like, rocks. <***yKen> What's the proper way to loop through an array? <freeone3000> With a for loop, a foreach loop, or a while loop plus incrementor, aka for loop. <***yKen> Cool. <***yKen> Thx. <callipygous> why is php titty ****ing the error messages/ <TJNII> Eloquently put. <onefang> That's just his style. <TJNII> Well. I guess I haven't idled in here long enough, then. <onefang> Neither have I, I've seen his style in other channels. <TJNII> Touche. <onefang> Well, having not idled in here for long enough, I'll ask my question anyway. <Zyclops> erm <onefang> PHP is leaking memory like a fire hose here. It seems to be loading fresh copies of the scripts into ram each time I load a new page, and keeping the old ones in ram. That's probably wrong though, ol is it a know issue? <Zyclops> count(array1) + count(array2) should equal the number of cells in the first array + the second <onefang> Give us more info you are sure to tell me. B-) <Zyclops> i have 2 arrays, one with 4 things in it, the other with 1,... when i add the first array to the second array i get 2 but 1 + 4 != 2 <Zyclops> adding = count(arr1) + count(arr2) <***yKen> How can I have a function return an array? <Zyclops> function bla() { var whatever = array(); return whatever;} <***yKen> I have to use var? <***yKen> Can't use $ <freeone3000> Or a dollar sign. <***yKen> ? <Zyclops> no <kuja> Zyclops: I don't think he was asking about JS. <***yKen> Hrm. <freeone3000> $whatever = array(); return $whatever; <kuja> function foo() { return array(); } <Zyclops> kuja: yeah whoops, thats what happnes when you spend all day alternating <kuja> :) <***yKen> Wierd...will "$array[] = "bla bla" automatically increment the array? <Zyclops> yes <kuja> ***yKen: Yes, why wouldn't it? <***yKen> I dont know -- I'm not having trouble. <***yKen> How do I access the awway as a return? <***yKen> $orders = Array(); <***yKen> orders=arrayFunction(); <***yKen> $orders=arrayFunction(); <***yKen> Is that right? <freeone3000> Yeah, that one. <freeone3000> The seconed. <kuja> ***yKen: function foo() { return array('kuja', 'is', 'cool'); } echo implode('', foo()); <***yKen> So odd..it's not working. <freeone3000> Of course, returns on functions arn't restricted codewise. <onefang> It may not be the scripts that are being reloaded into ram each time, but something huge is. <freeone3000> if(c=='1') { return 5; } else { return array(); } is legal... <kuja> Though I would throw away the else. <kuja> if ($foo) { return $bar; } return $baz; <freeone3000> imo, it's sorta ugly like that. <kuja> I'm not a big fan of redundant code. <kuja> Personal preference. <freeone3000> No, I mean functions returning whatever they darn well please. <kuja> As long as it's documented, it doesn't matter. <kuja> And of course well, it better be doing what it's supposed to be doing. <***yKen> $data = array(); <***yKen> $data[] = $location; <***yKen> return $data; <***yKen> oops sorry <***yKen> Thought that'd print on one line <kuja> That is valid code, ***yKen. <***yKen> Man...then I dont know why it's not working. <freeone3000> Is it in a function? <***yKen> Is this okay: foreach ($orders as $value) { <***yKen> Yea it's in a function <Zyclops> this is driving me nuts... why would count(arr1) + count(arr2) not work? <kuja> Zyclops: Cause you're doing something wrong. <Zyclops> i'm printing out the arrays, triple checking, everything <kuja> That's always the reason something isn't working. <ironpig_> hey kuju can I get your opinion on something? <freeone3000> It's working. <freeone3000> It's just not doing what you want. <ironpig_> its my php code again <kuja> ironpig_: Eh? <Zyclops> heh :) <freeone3000> <rant>WTF how can it be perm denied I just chmodded the entire dir to 777!</rant> <Zyclops> the individual counts work, the adding doesen't <***yKen> Hows this look: $orders = getOrders("2006-02-25","submit_cc"); <***yKen> That's to set the array <freeone3000> It looks like a function. <kuja> ***yKen: hashphp.org -- Paste your function. <***yKen> sec <tek> what does 'negated' mena? <kuja> tek: To negate something, the opposite of, what that isn't something that has been negated. <kuja> s/what/one/ <Zyclops> huh, guess what, you guys we're right... again <Zyclops> user error :) <kuja> tek: If you negate the letter 'a', then what isn't the letter 'a'? <tek> I get it. <***yKen> http://hashphp.org/pastebin.php?pid=6258 <kuja> A-Z, b-z, every other character except 'a' :) <sketch|work> is there any pre-built functionality to handle comma separated quoted lists? eg "Hello, there", "What is your name? .. i want [0] = "Hello, There" and [1] to be "What is your name?" <***yKen> implode <freeone3000> Implode... The opposite of explode, I presume? <freeone3000> Or you could just array("Hello, There", "What is your name?"); <kuja> ***yKen: So explain what isn't working correctly, now. <sketch|work> freeone3000: read my question again ... <***yKen> kuja, well it's only displaying one result when I call the displayOrders function...but the while loop puts many rows into the array...or so it should. <freeone3000> $this->array_type = MYSQL_***OC; is telling me that it expected a T_VARIABLE. <kuja> $data = array(); <kuja> $data[] = $location; <sketch|work> or i will re-phrase ... i want to break up a string based on commas (like explode), but i want to ignore commas within quotes <kuja> ***yKen: You're redefining the array each time you iterate. <kuja> So it gets emptied out. <***yKen> Ahhh. <***yKen> I see. <***yKen> So I need to set it as an array outside the while <kuja> Correct. <***yKen> Where I set location. <***yKen> Gotcha. <***yKen> Thanks :-) <kuja> ***yKen: $data = array(); while ( ... ) { ... } <***yKen> Works like a charm :-) <***yKen> Thank you very much. <***yKen> Also had to move the return $data outside the while <kuja> Right <***yKen> Now another question...is it possible to store arrays within an array? <kuja> Of course. <***yKen> So I could do this: <***yKen> $data1=array(); $data=array(); $data[]=$data1 and the whole array would be stored in the first element of the array? <freeone3000> Arrays, arrays of arrays, arrays of arrays of arrays, programing languages just love arrays. <kuja> ***yKen: Or just $data = array(array()); <onefang> APL loves arrays. B-) <kuja> PHP arrays aren't... "normal" <kuja> I guess really though, they're just sorted hashes. <TML> Erm <TML> kuja: That's a contradiction <TML> hashes are unordered by definition <freeone3000> It's like... a Java Map. <kuja> But I know not the term to cl***ify PHP arrays :) <freeone3000> Map, K->V. <will> Bring back kasia! <TML> kuja: PHP has "***ociative arrays" and "ordered (or indexed) arrays" <kuja> TML: They seem to be one in the same, or at least by the looks of it. <TML> kuja: They're not. <TML> They just live in the same place. <kuja> What would array('foo', 'bar' => 'baz', 'qux') be? I suppose that'd fall under ***ociative. <Ox41464b> $var[0]='foo';$var['bar']='baz';$var[1]='qux'; <kuja> Ox41464b: Terminology session, not syntax. <freeone3000> Sorry to break this up with a syntax problem but $this->array_type = MYSQL_***OC; seems to error for me, telling me it was expecting a type `T_VARIABLE' <TML> freeone3000: You can't ***ign a constant to a variable. <Ox41464b> php.net/array_combine <Ox41464b> er... nvm me <freeone3000> TML: Well... I could ***ign a method to a variable... <kuja> No you can't :) <freeone3000> TML: How should I handle something like that? Can I ***ign the value of a constant to a variable?
Return to
#php or Go to some related
logs:
BIOHAZRD ROM bochs dlopen failed for module 'x' ubuntu set DISPLAY:=1 libpangoxft undefined symbol: g_intern_static_string #perl linux verkkokomennot glftpd ubuntu rc.conf assembler AT #math #math
|
|