Jump to content

[SOLVED] Manipulating Array data...


skyer2000

Recommended Posts

I've pulled two strings from my database:

 

keyid = (1,5,7)

keyword = (foo1,foo2,foo3)

 

I can convert them to their own arrays by using the explode function, however, the array is:

 

array(0 => foo1, 1 => foo2, 2 => foo3);

 

When I need it to match the keyid for each keyword:

 

array(1 => foo1, 5 => foo2, 7 => foo3);

 

 

How do I combine them like that?

Link to comment
https://forums.phpfreaks.com/topic/157225-solved-manipulating-array-data/
Share on other sites

if you do something like

 

<?php

$keyid = '1,5,7';
$keyword = 'foo1,foo2,foo3';

$keyid_array = explode(',' , $keyid);
$keyword_array = explode(',' , $keyword);

$combined_array = array_combine($keyid_array, $keyword_array);

print_r($combined_array);

?>

 

I think that should give you the result you want.

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.