Lodius2000 Posted November 30, 2008 Share Posted November 30, 2008 this $replacement = $db->getAll('SELECT replacement FROM badwords ORDER BY id'); print_r()'s a this Array ( [0] => Array ( [replacement] => bl**d ) [1] => Array ( [replacement] => f*rt ) [2] => Array ( [replacement] => h*ll ) [3] => Array ( [replacement] => j*rk ) ) i $replacement to be an array that looks like $replacement = array (bl**d, f*rt, h*ll, j*rk) and i am at a loss as to how i tried foreach ($badword as $needle){ $needle = array($needle); } yeah, that didnt work help thanks Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/ Share on other sites More sharing options...
.josh Posted November 30, 2008 Share Posted November 30, 2008 foreach ($replacement as $val) { $r[] = $val['replacement']; } $replacement = $r; Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702623 Share on other sites More sharing options...
Lodius2000 Posted November 30, 2008 Author Share Posted November 30, 2008 crayon that print_r's as Array ( [0] => [1] => [2] => [3] => ) Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702626 Share on other sites More sharing options...
.josh Posted November 30, 2008 Share Posted November 30, 2008 yeah i changed it right after i posted. look again. i accidentally put 0 instead of replacement as key in foreach loop Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702627 Share on other sites More sharing options...
Lodius2000 Posted November 30, 2008 Author Share Posted November 30, 2008 ok so now im really confused $badword = $db->getAll('SELECT word FROM badwords ORDER BY id'); $replacement = $db->getAll('SELECT replacement FROM badwords ORDER BY id'); foreach ($badword as $v) { $b[] = $v['badword']; } $badword = $b; foreach ($replacement as $val) { $r[] = $val['replacement']; } $replacement = $r; print_r($badword); print "<br>"; print_r($replacement); prints Array ( [0] => [1] => [2] => [3] => ) Array ( [0] => bl**d [1] => f*rt [2] => h*ll [3] => j*rk ) why would it work for the one that you gave me ($replacement) and not the one that i modified it for ($badword) Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702629 Share on other sites More sharing options...
.josh Posted November 30, 2008 Share Posted November 30, 2008 column name from your badword query is 'word' but you use 'badword' inside your foreach loop. So either change 'word' to 'badword' in your query or else change 'badword' to 'word inside your foreach loop $b[] = $v['word']; Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702633 Share on other sites More sharing options...
Lodius2000 Posted November 30, 2008 Author Share Posted November 30, 2008 ima moron thanks Quote Link to comment https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/#findComment-702636 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.