256 Kilobytes

Answers in Server-Side | By Some Guy

Published 2 months agoFri, 11 Jan 2019 19:00:56 -0800

26 views, 0 RAM, and 1 comment

Profile Photo - Some Guy Some Guy
🗎 3212 🗨 40 🐏 26
Classic User

I'm working on the server-side of a PHP project and I'm wondering if I can split a string at a substring. For example, split this sentence into an array containing three substrings, broken at the commas:

  • "Red, White, Blue"

Does anyone have any experience with this that could help me understand it?

Download more RAM. 🐏 ⨉ 0 Posted by Some Guy 2 months ago 🕓 Posted at 11 January, 2019 19:00 PM PST

This is a patsy account used by the 256 Kilobytes staff to seed content. 

Profile Photo - August R. Garcia August R. Garcia Posting on Internet... Portland, OR
🗎 80 🗨 556 🐏 98
Site Owner

Try this:

<?php
  $t = explode(", ", $t); 
  print_r($t);

Docs:

If you need a more complex split, you can do this with a REGEX using preg_split():

Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 2 months ago 🕓 Posted at 11 January, 2019 19:03 PM PST

The CIA wants all code in the cloud under their lock and key. They want to ban compilers and make people think HTML is computer programming. - Terry A. Davis

Help improve our conversion rate and check out these nice goods. [info]

GeneratePress Review

Post a New Comment

To leave a comment, login to your account or create an account.

Do you like having a good time?

Read Quality Articles

Read some quality articles. If you can manage to not get banned for like five minutes, you can even post your own articles.

View Articles →

Argue with People on the Internet

Use your account to explain why people are wrong on the Internet forum.

View Forum →

Vandalize the Wiki

Or don't. I'm not your dad.

View Wiki →

Ask and/or Answer Questions

If someone asks a terrible question, post a LMGTFY link.

View Answers →

Make Some Money

Hire freelancers and/or advertise your goods and/or services. Hire people directly. We're not a middleman or your dad. Manage your own business transactions.

Register an Account
You can also login to an existing account or recover your password. All use of this site is subject to terms outlined in the terms of service and privacy policy.