Jump to content

Why doesn't this code work?


fert

Recommended Posts

[code]
$code=explode("\n",$_POST[code]);
$num=count($code);

for($count=0;$count<$num;$count++)
{
$code[$count]=str_replace("%","",$code[$count]);
$temp=explode("=",$code);

$vars[$temp[0]]=$temp[1];
}

print_r($vars);
[/code]
This code is suppose to extract a letter and a value from a string that looks like this "%a=5", but the array is empty and i can't figure out why.

When i use this code:
[code]
$code="%a=5";

$code=str_replace("%","",$code);
$temp=explode("=",$code);
$vars[$temp[0]]=$temp[1];

print_r($vars);
[/code]
I get
[quote]
Array ( [a] => 5 )
[/quote][/code]
Link to comment
https://forums.phpfreaks.com/topic/28476-why-doesnt-this-code-work/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.