?
Solved

create a new var

Posted on 2003-03-04
2
Medium Priority
?
212 Views
Last Modified: 2010-05-18
I would like to create a new var:
$i=3;
$a="test";

Now I need to create e new var, called b_3 with value of var a: "test"
In ASP it's
execute("b_"&i"="&a)


0
Comment
Question by:moswa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 15

Accepted Solution

by:
OMC2000 earned 200 total points
ID: 8063195
I guess you mean something like eval, don't you?

<?php
$i = 3;
$a = 'test';
eval ("\$b_$i = \"$a\";");
echo $b_3;
?>
0
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 8063218
you can use

$i=3;
$a="test";

$c = "b_".$i;

$$c = $a;

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question