Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:45:33+00:00 2026-06-01T06:45:33+00:00

I get an array using the function preg_match_all. The code is as it is:

  • 0

I get an array using the function preg_match_all. The code is as it is:

 $str = $dataGroups['groups'];
 preg_match_all('/[0-9]/', $str, $matches);

It return an associated array from the type:

array(5) { [0]=> string(1) "1" [1]=> string(1) "2" [2]=> string(1) "3" [3]=> string(1) "4" [4]=> string(1) "5" }

Where the values are actually id’s for a Link table, where I have two foreign keys, the values of the one FK are the values of the array above, what I need is to assign the keys with another value which should be the same for all elements because I\m gonna use it for multiple inserts in the table.So to make it clear If I want to insert all values which have id 67 I think I need something like this form my codeigniter active record:

array(5) { [67]=> string(1) “1” [67]=> string(1) “2” [67]=> string(1) “3” [67]=> string(1) “4” [67]=> string(1) “5” }

And use the AR command:

$this->db->insert(‘mytable’, $matches[0]);

I’m gonna try it for first time so any advice is appreciated, but the most important is to change the value of the keys with the same number, and maybe if you could tell if this is the right way to do the multiple insert using CodeIgniter AR.
Thanks

Leron

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:45:34+00:00Added an answer on June 1, 2026 at 6:45 am

    You cannot have duplicate keys in an array, they have to be unique as they are there for referencing!

    However, what you could do it have an associative array like so:

    $array = array(
        1 => array(
            'id' => 67
        ),
        2 => array(
            'id' => 67
        )
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following code to get an array with all sub directories from
I'm currently using the following PHP code: // Get all subordinates $subords = array();
How do I get the percentage and filesize from this sort of string using
I am trying to dynamically get a specific data array by using a function
I am trying to store values in array using JavaScript, but I get strange
I'm using jqGrid with the getChangedCells('all') to get an array of the rows in
I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
Currently I'm using file_get_contents() to submit GET data to an array of sites, but
I'm using Marshal.dump to serialize an array of objects, I need to get the
I need to call a static function from an object using the Singleton design,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.