skippt Posted November 23, 2013 Share Posted November 23, 2013 Hi, I'm doing some web scraping and at the end I end up with an array. $list[] = array('link' => $link, 'types' => $types); Sometimes name is empty so I end up with an array like this: Array ( [0] => Array ( [link] => [types] => Array ( ) ) [1] => Array ( [link] => [types] => Array ( ) ) [2] => Array ( [link] => http://example.com [types] => Array ( ) ) ) Is there any way I'd be able to get rid of all the values that are empty and so each new link starts at key 0? Thanks Quote Link to comment Share on other sites More sharing options...
.josh Posted November 23, 2013 Share Posted November 23, 2013 1) can you serialize the overall array and post that here, so that we can easily reconstruct the array 2) what is "name"? I see no "name" variable or element anywhere. 3) you provided a "before" array dump example (but refer to #1). Can you provide an "after" array dump example? IOW "this is what I have now. This is what I'd like it to look like." IOW don't just describe what you want, show the actual array structure as you want it to end up being. Quote Link to comment Share on other sites More sharing options...
Barand Posted November 23, 2013 Share Posted November 23, 2013 1) can you serialize the overall array and post that here, so that we can easily reconstruct the array ... or use var_export instead of print_r() Quote Link to comment Share on other sites More sharing options...
objnoob Posted November 23, 2013 Share Posted November 23, 2013 how are you scraping? Quote Link to comment Share on other sites More sharing options...
Solution QuickOldCar Posted November 23, 2013 Solution Share Posted November 23, 2013 Loop your array and either unset that result or can create a new array excluding those with blank values for links. Personally i would do checking for when are creating the arrays, maybe you are finding javascript links, maybe need to fix relative links, but obviously is something in your scraping code that should get attention. Quote Link to comment 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.