Jump to content

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)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.