combings arrays of numbers

Well, the programmer is always right! LOL… But, yes, you may have over-complicated it a bit.

Just FYI, you can take a 6-digit number and strip out each position with a small amount of code, which would allow you to dump all the arrays and the switches. A simple 6 to 12 line code would pull out the values and display the six “balls”.

Also, since you are learning, the best way to create a program is to first lay out the idea and look at all the possible ways you could create the project. Usually, if you look at the layout of the project, you will find a lot of ways to do the same thing. Then, think about the code involved and you will come up with a good way to do it. Of course, next you will see where you create too much code for a section (such as your 200 lines you dumped) and you can then look for possible better ways.

As you acquire experience, you will just “know” more and more ways to handle your programming idea. Then, pick the fastest and smallest code that works for you… So, just my thoughts on it all… Good luck!

Thanks.

I have yet to figure out how to pull out the individual numbers so I am taking the long road. lol.

From there, I’d have to figure out the timer part of code and make it work with my script.
It also accesses a database, which is way above me at the moment.

Not to mention the ‘easy pick’ feature.

whew!

Well, for “easy pick” you just use your rand() function again and limit to the span of your values… ( Easy! )

And, to pull out a digit, first you just “cast” it to a string. This means that the number is turned into a string.
That is done like this: (assuming $number is the random number) $num_string = (string)$number;
This gives you a string value for the number. Sooooo, from any “string” you can pull one letter which would
actually be your single number digit. In this case, if you wanted the 3rd digit, you would use somehting like:
$third_digit = substr((string)$number, 2, 1); Note, this simple line “cast’s” the number into a string and
then plucks out the 3 digit. Since a number such as 123456 would cast into a string like “123456”, you can
pull out any single digit using substr… One problem with this is that the number would have to be 6 full digits
because 6 digit numbers starting with a zero would cause problems… (Lots of ways around that in code!)
So, if your numbers all verified to all be 6 digits, no problems!

Hope all that makes sense… One simple line to pull out any digit. You can also use a variable instead of a
locked in starting number and loop thru it to pull a digit for displaying the numbered “ball” image…

Well, ALL THINGS can be programmed! LOL… Just some changes and it can be programmed smaller… Ha!

Thanks for response. Something I’ll definitely have to look into!

Lots to understand and work with.

The parentheses are hard enough to keep straight!

I’ll have to play around with that.

Well, paren’s are easy… They are mainly just used for two things. To send arguments to functions like this:

Some_Function(arg1, arg2, arg3)

And, to separate calculations in IF’s, etc… Like this: (note that an IF is actually a function of a sort)

If( $somevarible==“somevalue” and ($x!=$y) or ($totalvariable>100)) { do some code }

And, same with brackets: { } They are mainly used to group code for functions or IF’s…

Anyway, use php.net/manual to look up any of this type of thing… And, use w3schools.com for tutorials as they have really great ones… Good luck!

So what would cause this?

Allowed memory size of 134217728 bytes exhausted…

LOL, I got that error awhile back on a project. The number was a bit different…

Well, depending on the real error which can be shown if needed by altering the server’s error display settings.
Most likely it is that you overflowed the browser’s allowed memory stack. This is often because you set up a
loop and it counted too far or because you looped and filled an array with too much data.

The limit for PHP by default is 128megs. (1024x1024x1024, hence the 134meg number) If you feel this limit needs to be increased, you can use this command near the top of the PHP code:
ini_set(‘memory_limit’, ‘-1’); (Removes the limit…)

But, that is a huge amount of memory to be using. You can reach this limit by filling a variable with database data and not limiting the data pulled from the database. Not sure why your code is causing this. Could be several things. But, you can override it, but, most likely you should look at your code and look for loops that have no endings. (Or post it all here…) A loop that tests for some variable being over a value and the variable never changes, the loop would run forever…

Well, something for you to think about… Good luck, let us know…

Hmmm… I was testing using range with the minimum and maximum numbers I posted earlier, instead of using the 6 arrays limited to 0 through 9.

What’s weird is that it worked before when I was first playing around with php.

Well, there are a lot of setting in PHP for options such as memory usage. But, most likely it is just some small error in your logic of the code. Can you post the area that is causing the error and we can take a peek at it?

I found my error. I had typed range (x,y) instead of [b]rand/b.

And the subsr function shaved another 100 lines of code off. Thanks for that!

Plugging along nicely…

Oh, great! Range is different than Rand… LOL Totally different functions…

And, loosing another 100 lines of code is ALWAYS a smile!!!

Keep at it and let us know if you need further help! That is why we are here… Happy coding…

I’m sure I will need more help. It only gets more complicated from what I am looking at of the code I am using as a template.

I don’t know how to do the database part yet, I have to figure out how to make the numbers on the balls… which is really just for show. Then there’s the timer part, the easy pick section, and getting it to work altogether lol.

I’ll be back for sure.

I should hire someone… ha!

Sponsor our Newsletter | Privacy Policy | Terms of Service