Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    May 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Organizing/Shortening Different Variables With The Same Values

    Is there a way I can organize or shorten the coding when I have multiple variables with the same values?

    Example:

    PHP Code:
    $temp_1 "same value here";
    $temp_2 "same value here";
    $temp_3 "same value here";
    $temp_4 "same value here";
    $temp_5 "same value here"

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Will they always have the same values as eachother?

  • #3
    New Coder
    Join Date
    May 2006
    Posts
    94
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. I didn't notice the extra problem. The problem is the only value that would be different would be the $temp_# inside the str_replace function.

    Here's an example of what I have.

    PHP Code:
    $temp_2 str_replace("%title_description%"$_POST[title_description], $temp_2);
    $temp_3 str_replace("%title_description%"$_POST[title_description], $temp_3);
    $temp_4 str_replace("%title_description%"$_POST[title_description], $temp_4);
    $temp_5 str_replace("%title_description%"$_POST[title_description], $temp_5); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •