|
How to extract Numeric values from String
plz help
|
|
|
|
|
not sure if you mean you have a string with a number in it and need to pull just the string or if you have a number returned as a string.
but for the first you can separate the string using explode and then looping through the returned array and checking for is_numeric returning true and extracting that.
the second should be able to be used directly
$a = '1';
$echo 1 + $a;
but if there is a issue with it, you can use an explicit cast like in C (int)$a for example.
|
|
|
|
|
In the PHP documentation of Strings[^] there is a little snippet just over a third of the way down called "String conversion to numbers", which may help you.
Other than that, you could always go through the string char by char
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
I know this is a few days old but I thought I'd mention some new functionality in PHP. PHP Filters. Specifically:
<?php
$value01 = '123abc456def';
echo filter_var($value01, FILTER_SANITIZE_NUMBER_INT);
?>
Will Output:
123456
|
|
|
|
|
That's very useful. Bookmarked this for future reference, just in case.
If at first you don't succeed, you're not Chuck Norris.
|
|
|
|
|
|
I'm about to start a pet web project and I have chosen to use Python for it.
But, I'm stuck at the beginning, because I have a dilemma about the framework to use.
From what I saw, there are two frameworks I like, Django and web2py.
Anyone here has any real experience with these two, or have a good reason why one it better that the other?
[edit]
What's the matter? Nobody uses Django, nor web2py, nobody uses python, or nobody visits this forum?
[/edit]
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!
modified on Friday, November 20, 2009 2:07 PM
|
|
|
|
|
|
I did that, more that once.
There are a lot of people arguing that Django is the better choice, and a lot arguing the opposite.
Nevertheless...I chose Django. So far, I like it.
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!
|
|
|
|
|
Sorry for seeing the post soo late.
I don't know a single person using web2py in production so that may make it a tad scary to get started. I use Django and web.py professionally and it really is a question about your needs.
Personally, it took me some time to get comfortable with Django but now that I am I tend to prefer it.
And above all things, never think that you're not good enough yourself. A man should never think that. My belief is that in life people will take you at your own reckoning. --Isaac Asimov
Avoid the crowd. Do your own thinking independently. Be the chess player, not the chess piece. --Ralph Charell
|
|
|
|
|
I've made my choice, already
I decided to go with Django, and am quite happy with the decision, by now.
One of the biggest pros was the community around Django, something web2py can't really compete with.
After all, for learning a new framework, community tends to be quite important.
Where it seems there are only borderlines, Where others turn and sigh, You shall rise!
|
|
|
|
|
If you have questions about web2py and want more information about people running it on production, I would suggest you join (even if temporarily) the web2py google group. There are more than 1500 members and a lot of people using it in production who will be happy to share their opinions with you. You will find a very active community. The web2py community is younger therefore not as big as Django's.
As an axample, the PyCon 2010 registration site runs web2py in production. It used to run on Django but moved to web2py two years ago. http://us.pycon.org/2010/register
|
|
|
|
|
Hello,
I have created a web site in visual studio 2008 and sql server 2005. it contains a crystal report.
It works fine when hosted in IIS. but in apache server.. Report page in not coming for a long time.
finally its not coming. Please help me asap.
( # Is somthing else i have to write in apache config httpd ?)
|
|
|
|
|
Hi,
I am making a game, where I want to move the character with mouse click. It is a tile based game with isometric view.
# mouse move
if e.type==pygame.MOUSEBUTTONDOWN:
#movehero
movehero=True
if e.type==pygame.MOUSEBUTTONUP:
movehero=False
if movehero==True:
# the movement code
Can anyone tell me how to get the position of mouse click so that the character will move there itself?
Kindly help
Thanks
|
|
|
|
|
|
Scenario: a GUI allows to upload a .jpg and display on the page.
I successfully got the data of .jpg and uploaded into Oracle, the problem is the data row of this .jpg has length=0 and couldn't display the picture.
How can I check to see if the query(use to insert into database) bears the correct value before inserting? if yes, what might be the problem that oracle database doesn't have correct value?
Have spent a long time but couldn't figure out the issue, please give advice..thanks..
|
|
|
|
|
by the way, i used EMPTY_BLOB() as a locator..
|
|
|
|
|
I am trying to install LAMP in ubuntu
For that
I completed the following steps successfully in the order shown below
1. sudo apt-get install apache2
2. sudo /etc/init.d/apache2 start
3. sudo apt-get install php5 libapache2-mod-php5
4. sudo /etc/init.d/apache2 restart
After the above steps I created a PHP page named test.php in /var/www
The contents of test.php is
<?php<br />
echo "Hello World";<br />
?>
I am 100% sure that there is no syntactical errors in the php code.
But when I access the page using “http://localhost/test.php”, the following error showed
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/test.php on line 2
I don't know what to do at this situation. Please suggest me a solution.
|
|
|
|
|
Gjm wrote: I am 100% sure that there is no syntactical errors in the php code.
But when I access the page using “http://localhost/test.php”, the following error showed
Okay, then the code you're using is different from the code you've posted.
Try the following:
<?php
echo "Hello, World!";
?>
|
|
|
|
|
Gjm wrote: I am 100% sure that there is no syntactical errors in the php code.
But when I access the page using “http://localhost/test.php”, the following error showed
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/test.php on line 2
One of these statements must be false, I suspect it is the first one. The double quote characters around your string do not look correct, you should probably replace them with proper " characters.
|
|
|
|
|
I am trying to install LAMP in ubuntu
For that
I completed the following steps successfully in the order shown below
1. sudo apt-get install apache2
2. sudo /etc/init.d/apache2 start
3. sudo apt-get install php5 libapache2-mod-php5
4. sudo /etc/init.d/apache2 restart
After the above steps I created a PHP page named test.php in /var/www
The contents of test.php is
<?php
echo "Hello World";
?>
I am 100% sure that there is no syntactical errors in the php code.
But when I access the page using "http://localhost/test.php", the following error showed
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /var/www/test.php on line 2
I don't know what to do at this situation. Please suggest me a solution.
|
|
|
|
|
I just read it was out yesterday and i got it today, at least that's what it looks like. The link is sitting in firefox waiting for me to activate it.I was hit by the 2008 version and it cost me my hard drive, so i know what this one looks like. I'm running kubuntu now and am toying with activating it just to see if linux is as immuned as it claims. Too bad no attachments i got a screen shot. From exp i know any click on that box will activate it. If you get one shut it off with sys monitor. I'm wondering if i'm too late. When i open firefox it's still there, just the one small window opens. I tried chkrootkit and it didn't find it, if you know of a good linux scan tell me. Don't know what a reboot will do yet, i'm waiting, if i can find it i might be able to send it back.
modified on Sunday, November 15, 2009 8:25 AM
|
|
|
|
|
I know the first reaction is no, but I was musing over this and wanted to bounce the idea off of you good people.
First, why would anyone do this?
Well from my work environment, I work for a business that has multiple websites under different domains. For example I will use www.site1.com and www.site2.com. The sites are hosted on seperate servers. Both of these sites have their own product lines that they sell and a third party is hired to do data entry into both sites. All back-office web apps are designed in-house and the third party company can log into each sites product entry page to enter new items and update prices. But doing so requires a seperate login at each site.
Now reading up on moving php session data into a mysql database got me thinking a little additional work may permit multi-site logins. As I understand it a session is tied to a domain, which must be sent in each request for a given browser. In the datbase-based session storage this is stored, along with some other data. If a custom write and read is designed, one could also create a record for each additional domain that would want to share a login using the same session info with the domain info changed for each site.
Doing this of course means the various sites would need access to the same database, but it sounds like it would work to me. I am posting this so maybe those of you that have more experience with custom session solutions in PHP can poke holes in this idea before I start to work on it.
Chris J.
|
|
|
|
|
Hi...
I am building a website with php platform, suppose name is MyPhp.
We have another website which is developed with joomla.
Now I want to use a plugin which is developed in joomla in MyPhp website for search data from joomla database.
Thanks.
PUJA FALDU
|
|
|
|
|
Congratulations! I agree with your assessment that you want to do something. Now, what's the question?
|
|
|
|