soma56 Posted June 15, 2010 Share Posted June 15, 2010 Sometimes I receeive the following in my results: string(0) "" Does anyone know how I can remove them? Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/ Share on other sites More sharing options...
Alex Posted June 15, 2010 Share Posted June 15, 2010 In what results? Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072205 Share on other sites More sharing options...
soma56 Posted June 15, 2010 Author Share Posted June 15, 2010 <?php // Assuming the above tags are at www.example.com $tags = get_meta_tags('http://www.example.com/'); // Notice how the keys are all lowercase now, and // how . was replaced by _ in the key. echo $tags['author']; // name echo $tags['keywords']; // php documentation echo $tags['description']; // a php manual echo $tags['geo_position']; // 49.33;-86.59 ?> Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072208 Share on other sites More sharing options...
Alex Posted June 15, 2010 Share Posted June 15, 2010 By remove do you mean not display them if it's empty or what? You can use empty to determine if it's empty or not. We really need a better explanation & relevant code to help, you just posted an example from the manual. Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072216 Share on other sites More sharing options...
soma56 Posted June 15, 2010 Author Share Posted June 15, 2010 Sorry Alex. What's happening is that in some instances with the code below I'm receiving: string(0) "" I've tried to dump it and unset it however now it still echo's "NULL" [php <?php $tags = get_meta_tags('http://www.example.com/'); $data = explode(",", $tags['keywords']); foreach ($data as $value) if (empty($value)){ unset($value); var_dump($value); } else { echo $value . "<br />" . PHP_EOL; flush(); ob_flush(); usleep(500000); } } ?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072219 Share on other sites More sharing options...
Alex Posted June 15, 2010 Share Posted June 15, 2010 You want to remove it from the array? foreach ($data as $key => $value) if (empty($value)){ unset($data[$key]); var_dump($value); } else { ... var_dump will return NULL because it's... null. Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072221 Share on other sites More sharing options...
trq Posted June 15, 2010 Share Posted June 15, 2010 If the value is empty why are you using var_dump() on it? it is var_dump() that produces string(0) "" Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072222 Share on other sites More sharing options...
soma56 Posted June 15, 2010 Author Share Posted June 15, 2010 Thanks, had no idea that var_dump was causing. I appreciate everyone's' response. Quote Link to comment https://forums.phpfreaks.com/topic/204806-how-do-i-remove-string0-from-my-results/#findComment-1072238 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.