Jump to content

[SOLVED] help with array structure


Lodius2000

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/134917-solved-help-with-array-structure/
Share on other sites

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)

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.