if its not to much i just trouble can anyone offer any ideas as to how to investigate a string. i have 2 numbers
first number=806000842
second number=05234578
as u can see the two numbers are of different length with the first being 9 characters and the second being 8 characters. is there any function that is similar to the explode function where i can separate the characters and determine the value of the third character in the first number and the second character in the in the second number??

so far i have tried the explode function but that requires a separator and i have tried to create a function but that was not much success
can anyone help me out here
thanks

2
Contributors
1
2
Views
8 Years
Discussion Span
Last Post by OS_dev

if its not to much i just trouble can anyone offer any ideas as to how to investigate a string. i have 2 numbers
first number=806000842
second number=05234578
as u can see the two numbers are of different length with the first being 9 characters and the second being 8 characters. is there any function that is similar to the explode function where i can separate the characters and determine the value of the third character in the first number and the second character in the in the second number??

so far i have tried the explode function but that requires a separator and i have tried to create a function but that was not much success
can anyone help me out here
thanks

This should do it:

``````<?php
\$intNumOne="806000842"; //if we surrounds one with quotes, we should do it to all of them
\$intNumTwo="05234578"; //surround with double quote to preserve the leading 0, can be casted back to int at any time

\$valAt3rdOne = getCharAtLoc(\$intNumOne, 3); //get 6 from num one
\$valAt3rdTwo = getCharAtLoc(\$intNumTwo, 3); //get 5 from num two

function getCharAtLoc(\$strString, \$intLoc = 3)
{
\$intPadAmount = 9; //amount to pad strings and increase or decrease depending on length of values

//pad the string with 0s to the left until total length = \$intPadAmount