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 5969721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:16:16+00:00 2026-05-22T20:16:16+00:00

This is for an osCommerce contribution called (Automatically add multiple products with attribute to

  • 0

This is for an osCommerce contribution called
(“Automatically add multiple products with attribute to cart from external source”)

This existing code uses sscanf to ‘explode’ a string that represents a
– product ID,
– a productOption,

– and quantity:

sscanf('28{8}17[1]', '%d{%d}%d[%f]', 
  $productID,                       // 28
  $productOptionID, $optionValueID, //{8}17 <--- Product Options!!!
  $productQuantity                  //[1]
);

This works great if there is only 1 ‘set’ of Product Options (e.g. {8}17).

But this procedure needs to be adapted so that it can handle multiple Product Options, and put them into an array, e.g.:

'28{8}17{7}15{9}19[1]' //array(8=>17, 7=>15, 9=>19)
OR
'28{8}17{7}15[1]'      //array(8=>17, 7=>15)
OR
'28{8}17[1]'           //array(8=>17)

Thanks in advance. (I’m a pascal programmer)

  • 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-05-22T20:16:17+00:00Added an answer on May 22, 2026 at 8:16 pm

    Maybe regular expressions may be interesting

    $a = '28{8}17{7}15{9}19[1]';
    $matches = null;
    preg_match_all('~\\{[0-9]{1,3}\\}[0-9]{1,3}~', $a, $matches);
    

    To get the other things

    $id = (int) $a; // ;)
    $quantity = substr($a, strrpos($a, '[')+ 1, -1);
    

    According the comment a little update

    $a = '28{8}17{7}15{9}19[1]';
    $matches = null;
    preg_match_all('~\\{([0-9]{1,3})\\}([0-9]{1,3})~', $a, $matches, PREG_SET_ORDER);
    $result = array();
    foreach ($matches as $entry) {
      $result[$entry[1]] = $entry[2];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This little line of code here is from a shopping cart: <a href=javascript:; onclick=simpleCart.add(
I need to add several hundred products to an osCommerce (ugh, I know, it
In oscommerce, I have set the DIR_WS_IMAGES from the config.php to be an external
this is the code for my custom provider, mostly copied from the SDK notepad
This is my code: OleDbConnection connection = new OleDbConnection( Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\Offline.accdb;Persist Security Info=False); connection.Open();
This is my first post here and I wanted to get some input from
I am using oscommerce for my site. If product is purchased from certain state
I'm moving my site from an oscommerce store to a commercial application. The new
I am trying to port a site design from OSCommerce to Magento and I
This code is works fine when you type 22 and 56 for example, it

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.