Jump to content

fawkstrot

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

fawkstrot's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ultimately I ended up giving up on this and going with what I found to be the only way to accomplish what I needed to be done. I'm hoping you all here might have some insight and perhaps there's an easier way of doing what I am. This is what I am currently having to use: [code]$array_test = array (              'testelement'          => "Blah #holder_name#",         'testelement2'          => "Hello world",     );      function test_function(){     global $array_test;          $newvalue="stupid code";            $array_test['testelement']=str_replace('#holder_name#',$newvalue,$array_test['testelement']);              echo $array_test['testelement'];     echo "<br/><br/>";     echo $array_test['testelement2'];          } test_function();   [/code] This outputs: [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Blah stupid code Hello world[/quote] Consider $array_test basically a language array for a specific function. In that function I would like to replace certain values (for example the user name) with a value defined in the function. I tried doing this through various globals, etc., and just couldn't figure it out. Ultimately what I ended up having to do is put in the str_replace portion to put in the dynamic data I wanted inside of the array element. Ultimately if something like this could work (I know the code I'm going to paste won't, but hopefully you'll get the idea) I'd be very pleased... [code]$array_test = array (              'testelement'          => "Blah $holder_name",         'testelement2'          => "Hello world",     );      function test_function(){     global $array_test;          $holder_name="stupid code";              echo $array_test['testelement'];     echo "<br/><br/>";     echo $array_test['testelement2'];          } test_function(); [/code] If I could get that to output the same, or something like that, as the example above, I'd be greatful. It seems to me there has to be an easier way to do what I want to do. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.