Eve For Enterprise    Eve Support Community    Forums  Hop To Forum Categories  Resources  Hop To Forums  Development, & Software Talk    PHP - eval problems

Moderators: Mark Badolato
Go
New
Find
Notify
Tools
Reply
  
4-star Rating Rate It!  Login/Join 
Groupee Newbie
Posted
Hello, i've asked everybody and no one seems to know this problem.

I'm trying to turn a string into an array. The string contains "$array = array('key' => 'value'...);". I'm pretty sure that eval is my best bet, though i gave parse_str() a try.

Is this possible?
 
Posts: 7 | Location: Salina, KS | Registered: December 22, 2001Reply With QuoteEdit or Delete MessageReport This Post
Groupee VIP
Picture of Dave_L
Posted Hide Post
I just did this test, and it worked:

<?php

error_reporting(E_ALL);

$s = "\$array1 = array('key1' => 'value1', 'key2' => 'value2');";
eval($s);

var_dump($s, $array1);

?>


I had to escape "$array1" as "\$array1", since it's in a double-quoted string.
 
Posts: 1919 | Location: US | Registered: April 27, 2000Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

Eve For Enterprise    Eve Support Community    Forums  Hop To Forum Categories  Resources  Hop To Forums  Development, & Software Talk    PHP - eval problems