Re: arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



by the way, replace all the $data1 with $items in the example.

On 12/29/05, Andres Santos <asantos@xxxxxxxxx> wrote:
> thanks everybody for the tips, they have been very helpful. just one more doubt:
>
> imagine i have this array:
> $data1[0]['title'] = "hello world";
> $data1[0]['timestamp'] = 12345678;
> $data1[0]['data'] = "this is a test!";
> $data1[1]['title'] = "hello world again";
>  $data1[1]['timestamp'] = 87654321;
> $data1[1]['data'] = "this is a test again!";
>
> and i want to add a new key called ['blog_id'] with the same value to
> all of them, so the new array contains:
> $items[0]['title'] = "hello world";
> $items[0]['timestamp'] = 12345678;
> $items[0]['data'] = "this is a test!";
> $items[0]['blog_id'] = "whatever";
> $items[1]['title'] = "hello world again";
> $items[1]['timestamp'] = 87654321;
> $items[1]['data'] = "this is a test again!";
> $items[1]['blog_id'] = "whatever";
>
> this is what i have
>
> class rssmix {
>   var $feeds = array();
>
>   function mix($blog,$rss) {
>     $this->feeds[]['blog_id'] = $blog;
>     $this->feeds[]['blog_rss'] = $rss;
>   }
>
>   function other() {
>   ...
>   echo $this->feeds[$i]['blog_id']; //THIS PRINTS OK!!!
>   for ($j=0; $j<count($items); $j++) {
>     $items[$j]['blog_id'] = $this->feeds[$i]['blog_id']; //PROBLEM HERE!!!
>   }
>   ...
>   }
> }
>
> ..the value doesnt get catched ONLY inside the -for- loop. why?
> andres
>
>
> On 12/29/05, hernan Hernan Velasquez <hernamvel@xxxxxxxxx> wrote:
> >     You must do it manually
> >
> >  For concating, try using this function
> >
> >  function concat ( $arr1, $arr2 ) {
> >    $res = $arr1;
> >    $c = count ( $res );
> >    whlie ( list ($k,$v) = @each ($arr2) ) {
> >       $res[$c] = $v;
> >       $c++;
> >    }
> >    return $res;
> >  }
> >
> >  $data1 = concat ( $data1, $data2 );
> >
> >  For sorting is quite similar.
> >
> >  Hope it helps!
> >
> >  Hernan
> >   --- Andres Santos <asantos@xxxxxxxxx> escribió:
> >
> >
> >  > hi,
> >  > i have this array:
> >  >
> >  > $data1[0]['title'] = "hello world";
> >  > $data1[0]['timestamp'] = 12345678;
> >  > $data1[0]['data'] = "this is a test!";
> >  > $data1[1]['title'] = "hello world again";
> >  > $data1[1]['timestamp'] = 87654321;
> >  > $data1[1]['data'] = "this is a test again!";
> >  >
> >  > and then i have this other array:
> >  >
> >  > $data2[0]['title'] = "hello world!!!!!!";
> >  > $data2[0]['timestamp'] = 871428741;
> >  > $data2[0]['data'] = "this is anooother test!";
> >  > $data2[1]['title'] = "hello world again!!!??";
> >  > $data2[1]['timestamp'] = 371441412;
> >  > $data2[1]['data'] = "this is another test, again!";
> >  >
> >  > ...........
> >  > i need to
> >  >
> >  > 1st) append the second array to the first one in a
> >  > new array called $result
> >  > 2nd) resort the $result array by the timestamp.
> >  >
> >  > already tried a lot, but i keep getting problems
> >  > with the array stuff.
> >  > any ideas?
> >  >
> >  > thanks for your time,
> >  > andres
> >  >
> >  >
> >  > --
> >  > Slds,
> >  > Andrés Santos, IIG
> >  >
> >  > ******************************
> >  > móvil: (593) 9 7026627
> >  > e-sw: www.egobits.com
> >  > blogs: www.egoblogs.net
> >  > ******************************
> >  >
> >
> >
> >  Hernán Mauricio Velásquez
> >  Ingeniero Sistemas y Computación
> >  Universidad de los Andes
> >  Santafé de Bogotá
> >
> >  __________________________________________________
> >  Correo Yahoo!
> >  Espacio para todos tus mensajes, antivirus y antispam ¡gratis!
> >  Regístrate ya - http://correo.espanol.yahoo.com/
> >
> >
> >
> >
> >   PHP Data object relational mapping generator - http://www.meta-language.net/
> >
> >
> >
> >
> >      SPONSORED LINKS
> >                       Php developer                                       Basic programming language                                       Computer programming languages
> >                       Programming languages                                       Object oriented programming                                       Object oriented programming tutorial
> >
> >    ________________________________
>    YAHOO! GROUPS LINKS
> >
> >
> >  Visit your group "php-objects" on the web.
> >
> >  To unsubscribe from this group, send an email to:
> >  php-objects-unsubscribe@xxxxxxxxxxxxxxx
> >
> >  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> >
> >    ________________________________
>
>
>
>
> --
> Slds,
> Andrés Santos, IIG
>
> ******************************
> móvil: (593) 9 7026627
> e-sw: www.egobits.com
> blogs: www.egoblogs.net
> ******************************
>


--
Slds,
Andrés Santos, IIG

******************************
móvil: (593) 9 7026627
e-sw: www.egobits.com
blogs: www.egoblogs.net
******************************


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/KIlPFB/vlQLAA/TtwFAA/saFolB/TM
--------------------------------------------------------------------~-> 

PHP Data object relational mapping generator - http://www.meta-language.net/ 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-objects/

<*> To unsubscribe from this group, send an email to:
    php-objects-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 




[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux