IRC Networks
Irc Logs Stats
Start date: 2007-09-27 02:48:27
Last update: 2008-10-24 20:19:38
Channels: 41
Logged Lines: 6230436
Size: 1988.50 MB
Powered by
Channel Info
Network: freenodeChannel: #php |
Search in www.irclog.org
Log from #php at freenode 2006-07-29
Pages: 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
34
35
36
Next >
[00:00]<tjufgg>lo silver
[00:00]<vydag>are there any common practices for creating a multi-dimensional array out of a one-dimensional (with parent-ids)?
[00:00]<tjufgg>timcn: Umm huh?
[00:00]<tjufgg>R -> R^2 ?
[00:01]<rrppygrvnm>it's a carrot. you feed them to horses.
[00:01]<vydag>uhm
[00:01]<vydag>I don't know how to describe it easier
[00:01]<mdjgdede>timcn, I don't understand exactly your question
[00:01]<vydag>okay, I'll try to explain further
[00:02]<zzzdjdzvzzzzz>timcn: Before and after examples would help.
[00:02]<vydag>we at Drupal have a forms API where array indices beginning with # are properties, the rest are children of the current item
[00:02]<mdjgdede>aha
[00:02]<mdjgdede>okay this is possible
[00:02]<cvzjg|wjzc>hm, '/<style>([.\n]*)<\/style>/' doesn't seem to work.... preg_replace('/<style>([.\n]*)<\/style>/','',$html); should work I think
[00:03]<mdjgdede>timcn, you have to travel through your array...
[00:03]<mdjgdede>timcn, and always keep the parent item stored
[00:03]<mdjgdede>timcn, foreach ($array as $item) {
[00:03]<vydag>I know what a foreach loop is
[00:03]<d9fu7>or do you?
[00:03]<mdjgdede>timcn, if (substr($item, 0, 1) == '#') { ... set parent item here ... } else { $targetarray[ $parentitem ][ $property ] = $value }
[00:03]<mdjgdede>timcn, }
[00:04]<cvzjg|wjzc>dionyziz: were you and/are you involved with Node IRC?
[00:04]<mdjgdede>timcn, never doubted that you did :)
[00:04]<vydag>I have for example an array like that: array(1 => array('#title' => 'foo', '#parent => 2), 2 => array('#title' => 'bar
[00:04]<mdjgdede>Ktron|work, yes hey :)
[00:04]<mdjgdede>Ktron|work, this is funny
[00:04]<vydag>its more complicated than that, dionyziz
[00:04]<vydag>now, 1 is a child of 2
[00:04]<mrg__v>hi.
[00:04]<mrg__v>Does PHP have a function similar to the tool 'dig'?
[00:05]<vydag>it should result in that: array(2 => array('#title' => 'bar', 1 => array('#title' => 'foo', '#parent => 2));
[00:05]<tjufgg>dan__t: sort of, dig does a lot, what specifically are you looking for
[00:05]<vydag>thus, 1 being inside the 2-array
[00:05]<mrg__v>Er, I want to be able to pull the nameservers for a given domain.
[00:05]<zzzdjdzvzzzzz>dan__t: http://us2.php.net/manual/en/ref.network.php
[00:05]<mdjgdede>timcn, I see...
[00:06]<tjufgg>dan__t: dns_get_record
[00:06]<mrg__v>omfg.
[00:06]<mrg__v>amazing.
[00:06]<mdjgdede>timcn, I think the best way to do that would be using an OOP approach
[00:06]<mdjgdede>timcn, have a class where you can ->AttachChild
[00:06]<mrg__v>Thank you very much.
[00:06]<vydag>dionyziz: unfortunately, that's impossible as I'm tied to arrays
[00:07]<mdjgdede>timcn, you can use the classes as an intermediate step...
[00:07]<mdjgdede>timcn, arrays --> classes --> arrays
[00:07]<mdjgdede>timcn, so the input and output are arrays
[00:07]<vydag>hmm
[00:07]<mdjgdede>timcn, my suggestion would be to have an array of class instances...
[00:07]<vydag>that's pretty ineffective
[00:07]<mdjgdede>$allitems[ $yourindex ] = $yourinstance
[00:07]<tjufgg>oop is murder
[00:07]<mdjgdede>then you can do $allitems[ $yourindex ]->AttachChild( $someotherinstance )
[00:08]<mdjgdede>timcn, well, as a first idea it works :P
[00:08]<vydag>dionyziz: also, I don't see the advantage over arrays
[00:08]<vydag>with arrays, I can use array_merge()
[00:08]<vydag>or just +=
[00:08]<mdjgdede>timcn, do you have a WORKING way do to it with arrays?
[00:08]<mdjgdede>to have infinite depth?
[00:08]<vydag>currently not
[00:08]<mdjgdede>let's say that item #1 has more children
[00:08]<mdjgdede>;P
[00:09]<vydag>converting a nested tree into a multidimensional array is pretty similar to my problem
[00:10]<tjufgg>timcn: In which language?
[00:10]<tjufgg>An implmentation of a nested tree in php can be a multidimensional array
[00:10]<vydag>err, what do you mean, Touqen?
[00:11]<tjufgg>So you wouldn't really be converting anything
[00:11]<vydag>I mean the SQL storage model of a nested tree
[00:11]<tjufgg>Regardless, So what you want to do is take your relatively flat tree and give it some volume.
[00:11]<vydag>yes
[00:12]<tjufgg>Okay, so why not just iterate over your flat tree, check each nodes parent and add it to an array which is associated with that parent.
[00:12]<mdjgdede>Touqen, good approach
[00:20]<vydag>I think I'll better sleep a night over it
[00:21]<zyacjs>php suxx ! get J2EE or ASP.NET
[00:22]<ygv_zzl[wjzc]>Zickos: err ok...
[00:24]<curr>J2EE maybe, but no ASP for me... well he did say .NET though :P
[00:25]<fyvx>Someone explain to me _WHY_ when i have error_reporting(E_ALL); as the 1st line in my program does it still just parse a blank white screen?
[00:25]<mumns>I wanted to make a download.php script, so you I can download things from "non-web" folders (and this isn't as unsecure as it sounds). However, I am unsure where I should start googling. If someone has a pointer it would be appriciated.
[00:25]<cdlxnzus>Can you call an class with an array ?
[00:25]<fyvx>cypherus: no
[00:25]<cgazznvan>hello
[00:26]<fyvx>cypherus: wait... what do you mean?
[00:26]<cdlxnzus>$this->test['something'] = ";
[00:26]<fyvx>cypherus: definatly if $this->test is an array...
[00:26]<cgazznvan>how can i get xslt support in php 5.1?
[00:27]<curr>dudes: Take a look at the source code of existing ones.
[00:27]<mrg__v>./configure --help will show you, no?
[00:27]<fyvx>cypherus: you can do public $array = array('one' => 1 ,'two' => 2 ,'three' => 3); function __construct(){ print $this->array->one; }
[00:27]<mumns>kuja - I'm not sure where I would start looking =[
[00:27]<tjufgg>crap, i could do it but I've got to go home :/
[00:27]<curr>dudes: Then you're probably not ready to make it.
[00:27]<tjufgg>timcn: Try a stack based approach though.
[00:28]<fyvx>I'm spending more time debugging this stupid white screen then it is worth my frickin time!
[00:28]<mumns>kuja - I can write php, I just read stuff off the net and put the pieces together. (I normally write in C++).
[00:28]<tjufgg>Don't hodgepodge.
[00:29]<tjufgg>Especially if you don't understand it.
[00:29]<cdlxnzus>lith, ok.. thanks!
[00:29]<curr>Any 6 year old can write PHP, but that doesn't mean you know it.
[00:29]<fyvx>hodgebodge?? ;) I've never heard that used in a practical sense
[00:29]<curr>If you don't even know where to start looking for such a simple script as that, then you're obviously not ready to make it.
[00:29]<cgazznvan>well, i got libxml2 though :/ only no xslt listed in phpifno







