X Times using the same function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
egturnkey
Forum Commoner
Posts: 34
Joined: Sun Jul 26, 2009 7:35 pm

X Times using the same function

Post by egturnkey »

Hello friends,

i'm getting error due to using an function for 3 times in same time

if i've 3 results and i want to base36_encode the 3 output
it only encode one and then gives me error

Cannot redeclare base36_encode() (previously declared)

here is the code

// this is the encode function //

Code: Select all

function base36_encode($base10){
return base_convert($base10,10,36);
}
// i'm getting output here as 3 times (id) //

Code: Select all

$id = base36_encode($line[id]);
echo "$id<br>";
the out but should be like this
id1
id2
id3

all have been base36 encoded

but it only show the 1st one

id1
and the rest gives me the error above...

so how can i make it works for all results not only the 1st one

thanks everybody
cpetercarter
Forum Contributor
Posts: 474
Joined: Sat Jul 25, 2009 2:00 am

Re: X Times using the same function

Post by cpetercarter »

You have constructed your code in such a way that each time you declare the function base36_encode() and then run it. This is wrong. You can run the function as many times as you like, but you should declare it only once.
Post Reply