[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


add 4 characters to 32 character string

Posted on 2012-08-29
Medium Priority
Last Modified: 2012-08-30
32 character string.
add 4 characters on these positions


adding WXYZ

this is a related question for a smaller string which I thought was correct
Question by:rgb192
LVL 58

Expert Comment

ID: 38348086
A nonsensical question because even in the previous question you did not say how the string should be added to

Author Comment

ID: 38348492

W place 7
X place 13
Y place 23
Z place 31

other question was (in my opinion) correct
LVL 14

Accepted Solution

Scott Madeira earned 2000 total points
ID: 38348565
you need to read the PHP documentation on substr() to solve your problem.  If you are inserting 4 characters then you need to take the starting string, break it into the 5 appropriate pieces using a series of substr() and concatenate the 5 substrings and the 4 characters together.  This will get you started. You should be able to complete it and therefore understand what you are doing on your own.

$old = '0123456W789abXcdefghijkYlmnopqrZstuv';

$new = substr($old, 0, 7) . 'W' . substr($old, 8, 5) . 'X' ......

echo $new;
LVL 111

Expert Comment

by:Ray Paseur
ID: 38349956
Can you please tell us in plain language why you would want to do this?  I have years of computer science study and work experience and I have never seen anyone with a need for this kind of data manipulation, so it makes me think that there is an underlying question, not yet in evidence here.  Perhaps if we discuss that question we can get you to a better answer than substring concatenation.

Standing by, ~Ray

Author Closing Comment

ID: 38352353
this worked for me

thank you

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month19 days, 19 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question