Jump to content

Stripping characters from an array


slpctrl

Recommended Posts

Alright, this is a continuation from my last thread, so sorry if that's frowned upon or whatever. Here's my code as it stands:

 

<?php
function getpixels($pic){
$image = imagecreatefrompng($pic);
list($width, $height) = getimagesize($pic);
$height = $height/2;
$vars = array();
for ($i=0; $i<=$width; $i++){
  $color = imagecolorat($image, $i, $height);
  array_push($vars, $color);
}
return $vars;
}
$pixls = getpixels("http://www.hellboundhackers.org/challenges/timed/timed7/barcode.php");
foreach($pixls as $pixl){
echo $pixl;
}
?>

 

And it's output (for what I'll be doing) should look something like so:

 

0000000000101010111101011110010011011110100010110111101010101101100100001011101001100110101110011100101010000000000

 

Now, I need to remove the initial zeros and the zeros on the end (as they just stand for the border of a barcode). How would I go about doing this?

Link to comment
https://forums.phpfreaks.com/topic/143290-stripping-characters-from-an-array/
Share on other sites

lame.  what's the fun in doing a challenge when you're asking for other people to do it for you?

 

I just ask, and I don't even know why. 99.9% of the time I have it before anyone replies. I need to quit doin that. And, I've only asked for help twice. Don't have a hissy fit, nancy.

The questions I'm asking are really to bigger problems I'm having with the code; to say I've asked for help the entire bit of the way is ridiculous. I thought that my result was supposed to be in binary, and it's not. Even with stripping the border, I can't seem to do anything with it anyways. The 0s are the white space, 1s are black. I need to strip the borders off of that (done), and then calculate the UPC number of the barcode and I don't know how to even begin analyzing this to find out the UPC number. I would go straight on the HBH forums to ask for help, but only one person has solved this challenge.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.