Jump to content

using substr/str_replace on a variable


croakingtoad

Recommended Posts

Greetings!  I am querying a database and after a little magic it outputs a variable called - $HomeStyle

 

Now, this is a migration script so I am migrating from a database that has a field length of 3000 to a database that has a field length of 250.

Here's a sample value:

$HomeStyle= "Adirondack-style,Cabin,Cedar shake,Conventional,Cottages,Farmhouse,Lake";
//Obviously this is less than the needed field length, but let's just pretend so we can save space!

 

So how would I take the value of $HomeStyle, reduce it to 250 AND eliminate any characters after the last comma (including the last comma)?  (So we don't have incomplete words.)

 

Thanks for your guidance!

Link to comment
Share on other sites

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.