I have a string like this.

$function = "
array_splice($arr . $arrayimploded, end($index), 1, $data);
";

$arr is an array

$arr = array(0 => array(0 => "s",
1 => "es"),

1 => array(0 => "ing"),

2 => array(0 => "d",
1 => "ed")
);

The $arrayimploded is "[0]"

The end($index) is "1"
The $data is "bob"

So I'm trying to get php to do interpret that message as

array_splice($arr[0], 1, 1, 'bob');

I don't know how to use eval() and nothing on google seems to tell me how to use it.

Thanks in advance.

Recommended Answers

All 2 Replies

What makes you have $arrayimploded as "[0]"? Why not just 0 and use the function properly:

array_splice($arr[$arrayimploded], end($index), 1, $data);

If you can avoid eval(), avoid it.

Cause the amount of the [] things keys are unknown and I had to implode the number before hand. Anyhow Someone already beat you to it and sorted it out. Thanks anyway.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.