RecoilUK Posted July 3, 2008 Share Posted July 3, 2008 Hi guys Cant seem to get my head around why this wont work ... public function ParseResult($box, $file, $keys, $result) { $html = $this->GetTemplate($file); $keycount = count($keys) - 1; for ($i = 0; $i <= $keycount; $i++) { $datakey[$keys[$i]] = "<DATA:$keys[$i] />"; } print_r ($datakey); echo "<BR>"; } While this does ... public function ParseResult($box, $file, $keys, $result) { $html = $this->GetTemplate($file); $keycount = count($keys) - 1; for ($i = 0; $i <= $keycount; $i++) { $datakey[$keys[$i]] = "< DATA:$keys[$i] />"; } print_r ($datakey); echo "<BR>"; } Its the part in the for loop. Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/ Share on other sites More sharing options...
.josh Posted July 3, 2008 Share Posted July 3, 2008 You posted the same code block. Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580948 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 Actually, he has an extra space before DATA in the second one. Does it give you an error? Also, you aren't closing the for loop. o-O Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580949 Share on other sites More sharing options...
TransmogriBenno Posted July 3, 2008 Share Posted July 3, 2008 Try putting {} around the array element that's included in the string, i.e. $datakey[$keys[$i]] = "<DATA:{$keys[$i]} />"; Also, assuming that's the end of the function, you're missing a closing brace. The indentation is pretty bad. Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580951 Share on other sites More sharing options...
.josh Posted July 3, 2008 Share Posted July 3, 2008 damn maybe it's time to renew my contact prescription :/ Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580952 Share on other sites More sharing options...
DarkWater Posted July 3, 2008 Share Posted July 3, 2008 damn maybe it's time to renew my contact prescription :/ I ran diff on the line, not even kidding. It took me a while too. D: *Sad stare* Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580953 Share on other sites More sharing options...
RecoilUK Posted July 3, 2008 Author Share Posted July 3, 2008 Hi guys Yeah, it gives me an error, with the space its fine, but without it the variable value is blank. As far as the closing of the for loop, bad copy and paste i,m afraid Thanks Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580954 Share on other sites More sharing options...
RecoilUK Posted July 3, 2008 Author Share Posted July 3, 2008 No joy with the curly braces {} either. Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580955 Share on other sites More sharing options...
mbeals Posted July 3, 2008 Share Posted July 3, 2008 have you tried just to echo DATA:$keys[$i] within the loop to see if it really has the value you think it does? Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580974 Share on other sites More sharing options...
RecoilUK Posted July 3, 2008 Author Share Posted July 3, 2008 Can I get the plonker of the day award? It is working, but because its valid xhtml markup, it doesnt appear, only when you look at the source. Should have known really, as thats the effect I was going for lol L8rs Quote Link to comment https://forums.phpfreaks.com/topic/113097-solved-cant-assign-a-var-this-value/#findComment-580998 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.