maumesh Posted September 22, 2006 Share Posted September 22, 2006 hey frens i am reallly in troublei have some numbers like 1231.23,254.34,21.2 and so on .........now i need a php program that will give the output like1> 1000 200 30 1 and 23 after the decimal2> 200 50 4and 34 after the decimaland so onnnnplz help me fasttttttttttttttttttttttttt Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/ Share on other sites More sharing options...
trq Posted September 22, 2006 Share Posted September 22, 2006 What part are you stuck on? Were not here to write code [i]for[/i] you, we [i]help[/i] people when there stuck.Post your code. Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96550 Share on other sites More sharing options...
maumesh Posted September 22, 2006 Author Share Posted September 22, 2006 <?php$value=$_POST['value'];echo "$value<br>";if (ereg ("([0-9]{1}[0-9]{1}[0-9]{1}[0-9]{1})", $value, $regs)) { echo "$regs[1]";} else { echo "failure";}?>this code really doen't work at alll i knowwwplz help me out Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96552 Share on other sites More sharing options...
maumesh Posted September 22, 2006 Author Share Posted September 22, 2006 okkkkkkcan u do atleast one favorcan u help me out to get the string before the "." in the number 32.54i.e to get only 32<?php $no = '32.54'; $no1 = stristr($no, '.'); echo $no1; // outputs .54?> but i need to print 32help on this mannnn Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96577 Share on other sites More sharing options...
steveclondon Posted September 22, 2006 Share Posted September 22, 2006 use the floor() function. Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96580 Share on other sites More sharing options...
maumesh Posted September 22, 2006 Author Share Posted September 22, 2006 $value=231.25;//echo "$value<br>";$a=floor($value); echo $a;// 231now i want to put the output in the array as a(0)=1 a(1)=3 a(2)=2how to do that Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96595 Share on other sites More sharing options...
maumesh Posted September 22, 2006 Author Share Posted September 22, 2006 $no=123;now how to store 123 in the different variable; Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96598 Share on other sites More sharing options...
steveclondon Posted September 22, 2006 Share Posted September 22, 2006 there are a number of different ways to do that you can either split it by a string part 1 in 1 2 in the other etc. or you can use an array function perhaps to split it. Rather than me go through all of that here you should download the manual in chm format here: http://www.php.net/download-docs.php and then look up string functions. You need the str_pos fuction along with the strlen and the trim fuction if you going to go the string route or lookup array functions. Sorry I don't have time to go through all of this this morning, however you should find all this information now I have given you pointers in the php manual. Link to comment https://forums.phpfreaks.com/topic/21636-ereg-how/#findComment-96602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.