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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:11:42+00:00 2026-06-09T17:11:42+00:00

I am storing numbers in a database with a string like 5,55,15,17,2,35 I want

  • 0

I am storing numbers in a database with a string like 5,55,15,17,2,35

I want to remove say number 5 from the string, keeping the comma seperation set like it is.

The problem with using str_replace() is that all of the 5’s will be removed. If i use str_replace('5,'', $string) thats fine, but the comma wouldn’t be after the 5 if it was in the middle of the string or at the end. That same str_replace would also remove part of 15, and 55,

Am i missing something?

  • 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-09T17:11:43+00:00Added an answer on June 9, 2026 at 5:11 pm
    $array = explode(',', $string);
    foreach ($array as $k => $v)
      if ($v == 5) unset($array[$k]);
    $string = implode(',', $array);
    

    You probably shouldn’t be storing a comma separated list of values in a single database column in the first place. It looks like a one-to-many association, which should be modeled with a separate table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In C# I can generate random number from a string like this: public string
I want to create a database query string which should be like this, (SELECT
I have a database storing VIN numbers (stored as VID) for vehicles which are
I have this string of numbers var array = 1,6,2,9,5 which is retrieved from
I have a phone number like this: 025639879 . I got it from the
I use a form where i have listed the data from database like title,
In my program I get a number of strings from a remote SQL database
I have a string field in database that keeps numbers as string. when I
I want to insert any number was entered by the user, to the database
What is a good data structure for storing phone numbers in database fields? I'm

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.