Please help me. how to display only value on Laravel.
when i'm var_dump($data->count_date)
i got like this.
int(347)
how to remove int()?
Thks
php var_dump — Dumps information about a variable, not the variable alone.
$data->count_date is an integer number value, you can use it like any other integer, for example:
$value=$data->count_date+1;
Just do, It will only return the value.
dd($data->count_date);
Related
I am making a dashboard using php and displaying it on webpage using html. For this I am taking some count values. Is !$value[" variable"] valid in php? How do i get the not of (!=) value? There is no other way to get the data. I am getting the values from a database.
print "<td><a href=\"$strBase and status!='Closed'\" target=\"_blank\">".$value[" ? "]."</td>";
I need to print !closed. Somehow I do not know how to pass that inside $value[].
If you want to use a variable as a key in order to retrieve a value from an array you can do as follows (I use a snippet of your code):
.$value[$myVar].
Where $myVar should be a string with the name of the key you want to retreive from $value
But anyhow, your question is pretty unclear so I'm not sure if this is what you are looking for.
You can check if the variable is empty(), i.e.:
if(empty($value["variable"])){
echo "variable is empty";
}
I wish to count how many rows in an array has a certain field set to some value (not Null).
Something like: count(isset($names->array_value)).
Is there a command in php for this?
you can check with this code:
if (isset($names['array_value']) && is_array($names['array_value'])){
echo count($names['array_value']);
}
You can use array_filter() and count the result, but since you'll have to write special function for it, simple foreach loop seems like best option to me.
i am retrieving result as array from the database using codeigniter like this:
Array([name]=>TempName [hobby]=>Programming)
and i would like to change the above array like this:
Array([0]=>Tempname [1]=>Programming)
i would like to change the key(name,hobby) from column name to integer value(0,1)....
i have no idea about this...how i can change the key from string to integer...
any help or suggestion would be a great help, thanks in advance....
In PHP you can use the array_values method http://uk1.php.net/array_values
array_values may be what you are looking for
I'm trying to get data from facebook. So I try to get the user_id from their arrays.
Problem is some user_id are SO LONG that when I try to get it it returns something like
1.00003247906E+14
instead of
100003247905698
How do I fix this? I need the actual user_id.
I tried using:
$targets = (string)($status->actor_id);
But its still returning the same.
You can try $targets = sprintf('%0.0f',$status->actor_id)
A quick fix of this :
printf("%14.0f", 1.00003247906E+14);
will print
100003247905698
$targets = (string)($status->actor_id); must be returning and invalid value, because the invalid value must already be inside $status
Are you actually printing the retrieved user_id directly (like via print_r($status))?
I'm getting a few rows from the DB with an ajax call in PHP and I save the result to an array with javascript.
Then I make some changes in the data and wish to update the DB.
So I use another ajax call for that but I can't manage to access the fields inside the rows correctly.
When I try this I get nothing:
echo $bArray[$i].branchId;
When I try this:
echo json_encode($bArray[$i].branchId);
I get ArraybranchId instead of the field value.
What's the correct way to access the field with php?
Try either for array:
$bArray[$i]['branchId']
or for object:
$bArray[$i]->branchId
depending which type $bArray[$i] is (array or object). You have not written in your question, so I showed both ways.
I take it branchId is the name of the field, and you want the value for that field?
If so, it's:
echo $bArray['branchId']; or
echo $bArray[$i]['branchId']
Edit: Also, you'll need to make sure you're using mysql_fetch_assoc not mysql_fetch_array!