Jump to content

Recommended Posts

hi phpfreaks,

 

I have two arrays that I am trying to combine.  I have been trying to use array_combine but it is not working . The result I am trying to achieve is displayed in the bottom code box. Has anyone got any ideas? :shrug:

 

$ticketArray = array (
'customerId'=>array('fishing', "'/[^a-z_-\s]/i'"),
'businessName'=>array('housing', "'/[^a-z_-\s]/i'"),			
'title' =>array( "high rise", "'/[^a-z_-\s]/i'");

 

$arr = array ( 0 =>'',  1 =>'', 2 =>'', 3 => '');

 

$result = array_combine($arr,$ticketArray);
print_r($result);

 

 

I am trying to achieve this?

$arr = array ( 0 =>'fishing',  1 =>'housing', 2 =>'high rise');

Link to comment
https://forums.phpfreaks.com/topic/243039-array_combine-problem/
Share on other sites

There is no rhyme or reason to your combine, other than you want the first item of the subarrays to match up with the second array.

 

$arr = array();
foreach ($ticketArray as $key => $val) {
     $arr[] = $ticketArray[$key][0];
}
var_dump($arr);

 

Should get you what you want, but might need more information if it doesn't work like you expect it to with all data.

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.