change string into variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BluaP

    change string into variable

    when going to index.php?headl ines=Macsanomat

    i want to use the $Macsanomat instead of Macsanomat (the string)
    this is needed to declare $Macsanomat into a loop.


    piece of the code:
    //------
    $Macsanomat['naam'] = "Macsanomat ";
    $Macsanomat['vlag'] = '<img src="finland.gi f>';
    $Macsanomat['tekst'] = "<b>News</b> powered by ";
    $Macsanomat['id'] = '714';

    if ($headlines !="")
    {
    echo $headlines['vlag'].'<a
    href="'.$headli nes['id'].'>'.$headlines['naam'].</a>';
    };
    //-------

    index.php?headl ines=Macsanomat

    in the last line $headlines['vlag'] should be <img src="finland.gi f>,
    $headlines['id'] should be 714. The value of both is now simply M


    anyone ?
    --

  • Jon Kraft

    #2
    Re: change string into variable

    BluaP <spam@bluap.n l> wrote:
    [color=blue]
    > when going to index.php?headl ines=Macsanomat
    >
    > i want to use the $Macsanomat instead of Macsanomat (the string)
    > this is needed to declare $Macsanomat into a loop.
    >
    > piece of the code:
    > //------
    > $Macsanomat['naam'] = "Macsanomat ";
    > $Macsanomat['vlag'] = '<img src="finland.gi f>';
    > $Macsanomat['tekst'] = "<b>News</b> powered by ";
    > $Macsanomat['id'] = '714';
    >
    > if ($headlines !="")
    > {
    > echo $headlines['vlag'].'<a
    > href="'.$headli nes['id'].'>'.$headlines['naam'].</a>';
    > };[/color]

    Have a look at the manual:


    HTH;
    JOn

    Comment

    • BluaP

      #3
      Re: change string into variable

      Jon Kraft <jon@jonux.co.u k> wrote:
      [color=blue]
      > BluaP <spam@bluap.n l> wrote:
      >[color=green]
      > > when going to index.php?headl ines=Macsanomat
      > >
      > > i want to use the $Macsanomat instead of Macsanomat (the string)
      > > this is needed to declare $Macsanomat into a loop.
      > >
      > > piece of the code:
      > > //------
      > > $Macsanomat['naam'] = "Macsanomat ";
      > > $Macsanomat['vlag'] = '<img src="finland.gi f>';
      > > $Macsanomat['tekst'] = "<b>News</b> powered by ";
      > > $Macsanomat['id'] = '714';
      > >
      > > if ($headlines !="")
      > > {
      > > echo $headlines['vlag'].'<a
      > > href="'.$headli nes['id'].'>'.$headlines['naam'].</a>';
      > > };[/color]
      >
      > Have a look at the manual:
      > http://uk.php.net/manual/en/language...s.variable.php
      >
      > HTH;
      > JOn[/color]

      sure did help!
      plain simple:

      if ($headlines !="")
      {
      $headlines2=$$h eadlines;
      echo $headlines2['vlag'].'<a
      href="'.$headli nes2['id'].'>'.$headlines 2['naam'].</a>';
      };

      did not know the $$ trick. thank you, thank you!
      --

      Comment

      Working...