one final question and i will finally get this working

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

one final question and i will finally get this working

Post by vincenzobar »

I need to take an array and chop it into 2 different arrays according to the Key

for example

Code: Select all

if(is_array($name)){
								foreach($name as $k4=>$attributes){
									$hold[] = strtolower($k4);
									$row = array_unique($hold);
									
									$content[] = $attributes;
$name is the main array
$hold holds the key names and the it parses to unique because all i need is 1 occurance of the key to use the implode to create a variable to use in MySQ Insert statements.

carrierdescription and carrierlogo

now $content holds the values of the keys and i need a way to parse them into seperate arrays to implode into MySQL

What do i use to cut an array up but "carrierdescription' and 'carrierlogo'?
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

my outp put looks like this

Code: Select all

('carrierdescription', 'carrierlogo')

and

('ALLTEL Wireless', 'images/carriers/AllTel_logo.gif', 'Cellular One', 'images/carriers/Cellularone-Lsf.gif', 'Cingular Wireless', 'images/carriers/cingularlogo.gif', 'Liberty Wireless', 'images/carriers/liberty_logo.gif', 'Nextel', 'images/carriers/nextel_logo.gif', 'Sprint PCS', 'images/carriers/sprint_logo.gif', 'StarBox', 'images/carriers/Motient_logo.gif', 'T-Mobile', 'images/carriers/tmobile_logo.gif', 'U.S. Cellular', 'images/carriers/uscellular_l.gif', 'Verizon Wireless', 'images/carriers/verizonLogo.gif')
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

This what you're looking for?

Code: Select all

foreach($array as $key => $val){
    if($key == "first"){
        $newarrayone[] = $val;
    }
    elseif($key == "second"){
        $newarraytwo[] = $val;
    }
    else{
        $junk[] = $val;
    }
}
Your question is confusing.
Post Reply